26 ms·
Working with Strings is so much better in post 1.8 ruby. Before it was hell with iconv especially for us guys who work primarily with non english languages. Th
by sunkencity 14y ago
Working with Strings is so much better in post 1.8 ruby. Before it was hell with iconv especially for us guys who work primarily with non english languages.
The default splitter for split is newline:
"foo\nbar".split => ["foo", "bar"]
Now possible to get the individual letters as characters in a simple UTF safe way:
"foobar".split(//) => ["f", "o", "o", "b", "a", "r"]
I like the stuff that has been done with enumerators, making it possible to map with index etc:
"foobar".unpack("U*").enum_for(:each_with_index).map { |x,i| x + i }.pack("U*") => "fpqeew"