Yeah, right. $FruitStand.apples is not a direct access to the attribute,
but a method invocation (a call to a method implicitly created by Raku), so
it doesn't get interpolated within the string. So it should be outside the
string or used with a code interpolation block.
For example:
say "Fruitst
Great, Laurent!
Works fine (and Todd's as well).
Thank you for the explanation.
--B.
On Sat, Dec 19, 2020 at 2:27 AM Laurent Rosenfeld via perl6-users <
perl6-us...@perl.org> wrote:
> Yeah, right. $FruitStand.apples is not a direct access to the attribute,
> but a method invocation (a call to a
apples.";
Is the "." at the end of the apples literal or syntax?
Hi All,
I have so far:
class BadMath {
has Int $.A;
has Int $.B;
method BadAdd() {
my $Clinker = (-5..5).rand.truncate;
return $!A + $!B + $Clinker;
}
}
my $TwoPlusTwo = BadMath.new( A => 2, B=> 2 );
print $TwoPlusTwo.BadAdd ~ "\n"
You can interpolate a method call in a string, but you need the parens.
say "$FruitStand.location() has $FruitStand.apples() apples in stock";
On Sat, Dec 19, 2020 at 4:28 AM Laurent Rosenfeld via perl6-users <
perl6-us...@perl.org> wrote:
> Yeah, right. $FruitStand.apples is not a direct ac
On 12/19/20 4:49 PM, Brad Gilbert wrote:
You can interpolate a method call in a string, but you need the parens.
say "$FruitStand.location() has $FruitStand.apples() apples in stock";
Cool! Now four ways of doing it:
print $FruitStand.location ~ "has " ~ $FruitStand.apples ~"
app
Going back to Dec 3rd explanation:
"... I had a chain of methods which should do some side effect.
It all went fine only the side effect was not there. I then figured
out after some time that one of methods returned Nil and
somehow silently it did not do what I expected."
This looks like an incom
Is this a known issue, or my misunderstanding?
> subset non-Nil where * !=== Nil;
(non-Nil)
> sub out-check($out) returns non-Nil { return $out }
&out-check
> out-check(44)
44
> out-check(Nil)
Nil
^ Huh, I expected an exception on "out-check(Nil)" saying the return value
failed the "returns" cons
> On Dec 19, 2020, at 6:40 PM, ToddAndMargo via perl6-users
> wrote:
>
> Hi All,
>
> I have so far:
>
>
> class BadMath {
> has Int $.A;
> has Int $.B;
>
> method BadAdd() {
> my $Clinker = (-5..5).rand.truncate;
> return $!A + $!B + $Clinker;
>
On 12/19/20 8:21 PM, Bruce Gray wrote:
On Dec 19, 2020, at 6:40 PM, ToddAndMargo via perl6-users
wrote:
Hi All,
I have so far:
class BadMath {
has Int $.A;
has Int $.B;
method BadAdd() {
my $Clinker = (-5..5).rand.truncate;
return $!A + $!B +
Hi All,
https://github.com/rakudo/rakudo/blob/master/src/core.c/Str.pm6
337:multi method contains(Str:D: Str:D $needle --> Bool:D) {
338:nqp::hllbool(nqp::isne_i(nqp::index($!value,$needle,0),-1))
339:}
I "presume" in
"abcd".contains("bc")
"abcd" is `$!value`, and
"bc" is $needle. Do
On 12/19/20 8:21 PM, Bruce Gray wrote:
With a custom `new` method, that could be shortened further to:
say BadMath.new(2, 2).BadAdd;
print BadMath.new(2, 2).BadAdd ~ "\n";
Default constructor for 'BadMath' only takes named arguments
in block at line 1
What am I missing?
12 matches
Mail list logo