00:38 Heptite left 01:47 Manifest0 left 02:24 Heptite joined 05:50 Heptite left 10:01 Heptite joined 12:04 Heptite left 14:27 Manifest0 joined 17:00 pk joined 17:02 Heptite joined
sampersand—2B +| +^2B == FF say $addition.function()(1, 2); # OUTPUT: «3␤» # OR say $addition.function.(1, 2); # OUTPUT: «3␤» is the () at the start explicit syntactic sugar for . in this case or is the fact that ()( and .( are the same a coincidence 20:26
sub squared( Int $num ) { $num² }; say squared($_) for ^5; # OUTPUT: «0␤1␤4␤9␤16␤» what's ^ for in ^5? 20:40
Oh that's a range
nahita3882 .() is short for () like .[] is for [] etc. (postcircumfixes listed here are the others) 21:48
operators are functions in disguise, sometimes they are in methods 21:49
in the case of these postcircumfix ones, the invocant is to implement CALL-ME etc.
that it's all uppercase means it's not expected to be called from the user side; it2s automatically called by the compiler when the corresponding sugar happens, i.e., .() for CALL-ME 21:50
kind of like the dunders of Python
in your first example, we infer that $addition.function is itself a callable and also evaluates to one 21:51
last thing to note is if you only "mention" the name of a callable (without & in front, so it's in the "verb" form, not "noun"), it gets called automatically 21:52
that's in play in the 3rd line in your first example 21:53
22:25 Heptite left 22:48 Manifest0 left 22:55 Manifest0 joined 22:56 Heptite joined
sampersand—2B +| +^2B == FF i got my example from teh operators page. I guess i wasnt super clear: .function.(1,2) makes sense, and it works if function is a field, because that way you aren't trying to call the method function like you would .function(1,2). What's not clear to me is why .function()(1,2) works the same way: wouldnt that call the field function with no args, then call that return value with two 23:41
args?