Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I was going to say you forgot the <code>package Dice</code> in your <code>Dice.pm</code>, but after reading up on Moops I am confused about the namespaces. </p> <p>Let's take a look at the <a href="https://metacpan.org/pod/Moops" rel="nofollow">documentation for Moops</a>.</p> <blockquote> <p>If you use Moops within a package other than main, then package names used within the declaration are "qualified" by that outer package, unless they contain "::". So for example:</p> <pre><code>package Quux; use Moops; class Foo { } # declares Quux::Foo class Xyzzy::Foo # declares Xyzzy::Foo extends Foo { } # ... extending Quux::Foo class ::Baz { } # declares Baz </code></pre> </blockquote> <p>If the <code>class Dice</code> is in <code>Dice.pm</code> it will actually become <code>Dice::Dice</code> if I read this correctly. So you would have to <code>use Dice</code> and create your object with <code>Dice::Dice-&gt;new</code>.</p> <p>In order to make the package <code>Dice</code> within <code>Dice.pm</code> using Moops, I believe you need to declare the class like this:</p> <pre><code>class ::Dice 1.0 { # ^------------- there are two colons here! has dieType =&gt; (is =&gt; 'rw', isa =&gt; Int, required =&gt; 1); has dieQty =&gt; (is =&gt; 'rw', isa =&gt; Int, required =&gt; 1); has finalResult =&gt; (is =&gt; 'rw', isa =&gt; Int, required =&gt; 0); method getStandardResult() { $self-&gt;finalResult(int(rand($self-&gt;dieType()) + 1)); return $self-&gt;finalResult(); } } </code></pre> <p>You can then do:</p> <pre><code>use Dice; Dice-&gt;new; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload