What's the difference between .. and ... in Perl 6?
For example, the following lines will produce the same output:
for 1..5 { .say };
for 1...5 { .say };
..
construct a range object (think mathematical interval).
...
constructs a sequence (think lazily generated one-shot list).
If all I want to do is iterate over consecutive integers (eg for indexing), I prefer he former (it's the less general tool, and a character shorter to boot).
If you need more precise control, use the latter (eg the idiomatic example for generating the Fibonacci sequence in Perl6 is given by the expression 1, 1, *+* ... *
, where he third term *+*
is the rule for inductively generating the elements).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With