Re: How do I address individual elements inside an object

2020-12-19 Thread ToddAndMargo via perl6-users
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

Re: How do I address individual elements inside an object

2020-12-19 Thread Brad Gilbert
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

Re: How do I address individual elements inside an object

2020-12-19 Thread ToddAndMargo via perl6-users
apples."; Is the "." at the end of the apples literal or syntax?

Re: How do I address individual elements inside an object

2020-12-19 Thread William Michels via perl6-users
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

Re: How do I address individual elements inside an object

2020-12-19 Thread Laurent Rosenfeld via perl6-users
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

Re: How do I address individual elements inside an object

2020-12-18 Thread ToddAndMargo via perl6-users
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 ***

Re: How do I address individual elements inside an object

2020-12-18 Thread William Michels via perl6-users
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

Re: How do I address individual elements inside an object

2020-12-18 Thread Parrot Raiser
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 $

Re: How do I address individual elements inside an object

2020-12-18 Thread Laurent Rosenfeld via perl6-users
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

How do I address individual elements inside an object

2020-12-17 Thread ToddAndMargo via perl6-users
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,