|
02:28
guifa_ left
02:29
guifa joined
07:32
guifa_ joined,
guifa left
|
|||
| disbot4 | <comborico> I want to make sure I have this correct. "A method's signature can restrict the class caller by listing the class as the first parameter and appending a colon." Example: method create-point(::?CLASS:U $BAZ: $foo, $bar) { $BAZ.new(x => $foo, y => $bar); } | 16:26 | |
| <librasteve> it is possible to interpolate class names from variables, but that is an advanced trick | 16:28 | ||
| <librasteve> here is typical thing that you could write: | 16:30 | ||
| <librasteve> method create-point(Shape:D: $foo, $bar) { $!top-left = Point.new(x => $foo, y => $bar); } | 16:32 | ||
| <librasteve> raku.land/zef:librasteve/Math::Polygons has some examples - contributions welcome | 16:34 | ||
| <librasteve> som in my example, you are calling this method with some code like: | 16:35 | ||
| <librasteve> my $square = Shape.new; $square.create-point(1,2); | 16:36 | ||
| <librasteve> and the type constraint on the invocant ($square) is Shape:D and that is delineated by a : colon from the rest of the Signature | 16:37 | ||
| <comborico> Thanks | 16:40 | ||
| <librasteve> i get the feeling that you are trying ::?CLASS:U to say something like "whatever calls this method must be the same class as the class I declare the method in? That is pretty confusing to me since you already must be that class of object to get dispatched to a method declared in that class ;-) | 16:46 | ||
| <comborico> True, I was trying to make sense of it myself. | 16:53 | ||
| <comborico> I appreciate the help! | |||
|
17:17
guifa_ left,
guifa joined
17:24
camelia left
17:27
camelia joined
20:43
librasteve_ left
|
|||