JavaScript programmers bring habits with them. Some of them help in Raku, and some get in the way. These articles start from what JavaScript does.
False friends
- + adds, even when the numbers are stringsIn JavaScript,
"10" + 5is"105", and in Python it is an error. In Raku it is 15, because+always adds. - == does not compare stringsIn Python and JavaScript,
==compares strings too. In Raku,==compares numbers, and strings are compared witheq. - 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. - 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.