Code that looks the same in Python, Perl or JavaScript and in Raku, but means something else.
A1 First words
A2 Everyday Raku
- @a[-1] is not the last elementIn Python and Perl, index -1 counts from the end. In Raku it does not even compile.
- 0.1 + 0.2 is exactly 0.3In Python and JavaScript,
0.1 + 0.2is not equal to0.3. In Raku it is, because0.1is stored as a fraction. - There is no length
len,.lengthandlengthdo not exist in Raku. A string has.chars, and a list has.elems. - // is not integer divisionIn Python,
7 // 2is 3. In Raku,//means "or else, if there is no value", so7 // 2is 7. - Splitting on nothing does not give you the lettersIn JavaScript and Perl, splitting on an empty string gives the characters. In Raku you also get an empty string at each end. Use
.comb. - my $n = @array is not a countIn Perl, putting an array into a scalar variable gives you its length. In Raku, the scalar holds the whole array.