rubyinside.com
26 Nov '12, 2pm
The Split is Not Enough: Unicode Whitespace Shenigans for Rubyists
The Split is Not Enough: Unicode Whitespace Shenigans for Rubyists By Peter Cooper / November 26, 2012 That code is legal Ruby! If you ran it, you'd see 8 . How? There's a tale to tell.. The String with the Golden Space I was on IRC in #nwrug enjoying festive cheer with fellow Northern Rubyists when ysr23 presented a curious problem. He was using a Twitter library that returned a tweet, "@twellyme film" , in a string called reply . The problem was that despite calling reply.split , the string refused to split on whitespace. Yet if he did "@twellyme film".split in IRB, that was fine. International man of mystery Will Jessop suggested checking $; (it's a special global variable that defines the default separator for String#split ). It was OK. In an attempt to look smarter than I am, I suggested reply.method(:split).source_location to see if the String class had been monkey-p...
Full article:
http://www.rubyinside.com/the-split-is-not-enough-whitesp...