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
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
apples.";
Is the "." at the end of the apples literal or syntax?
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
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
On 12/18/20 9:42 AM, William Michels via perl6-users wrote:
Hi Laurent, I get:
Fruitstand in Fruit<140431957910656>.location has
Fruit<140431957910656>.apples apples.
[Rakudo v2020.10]
Best, Bill.
Hi Bill,
From my notes in progress:
-T
*** addressing values inside and object ***
Hi Laurent, I get:
Fruitstand in Fruit<140431957910656>.location has
Fruit<140431957910656>.apples apples.
[Rakudo v2020.10]
Best, Bill.
On Fri, Dec 18, 2020 at 5:29 AM Laurent Rosenfeld via perl6-users <
perl6-us...@perl.org> wrote:
> Hi Todd,
>
> 1. Yes, a class is a blueprint for manufact
Although it's a standard term, "class" has a misleading connotation of "set".
Using the "fruit" example, the class Fruit should indicate a set of
relevant properties for a fruit, such as name, colour, taste, size,
possibly cost/kilo. Individual variables can be defined as Fruit-type
objects. Then $
Hi Todd,
1. Yes, a class is a blueprint for manufacturing objects, you can construct
as many object as you want.
2. As an example, you can try:
say " Fruitstand in $FruitStand.location has $FruitStand.apples apples.";
2. As you declared your class the object attributes will not be mutable.
But
Hi All,
class Fruit {
has Str $.location;
has UInt $.apples;
has UInt $.oranges;
has UInt $.bananas;
}
my $FruitStand = Fruit.new( location => "Cucamonga",
apples => 400,
oranges => 200,
10 matches
Mail list logo