I'm getting an unexpected return value with this code:
str = ''; 'abc'.chars.map {|c| str<<c}
Expected output:
["a", "ab", "abc"]
Actual output:
["abc", "abc", "abc"]
Adding a puts(str)
for debugging:
str = ''; 'abc'.chars.map {|c| puts(str); str<<c}
a
ab
=> ["abc", "abc", "abc"]
Why is the above code not returning the expected output? Thanks.