News for hackers. Stuff that matters.
Re:Lessons Learned Upgrading Harvest to Ruby 1.9.3 by techtalsky on Tuesday April 17, 2012 @10:56AM (#3852836)
Does anyone know why String.each was cut? String.each was one of the cool things that attracted me to ruby in the first place. I loved that you could say myString.each and it would assume you meant linebreaks unless you told it some other delimiter.
Re:Lessons Learned Upgrading Harvest to Ruby 1.9.3 by _pius on Tuesday April 17, 2012 @11:22AM (#3852972)
Strings were revamped in Ruby 1.9 to have more robust support of Unicode and other encodings. One of the side effects is that both the semantics and internal representation of Strings changed such that treating a String object as an Enumerable no longer made sense.

There's a good treatment of this here:

http://blog.grayproductions.net/articles/ruby_19s_string

Re:Lessons Learned Upgrading Harvest to Ruby 1.9.3 by techtalsky on Thursday April 19, 2012 @10:54AM (#3863280)
Thank you very much. I didn't realize that string handling was changed so much in 1.9. This has got to be one of the best string encoding methods in any programming language to date.
Re:Lessons Learned Upgrading Harvest to Ruby 1.9.3 by sunkencity on Tuesday April 17, 2012 @03:45PM (#3854602)
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"
Re:Lessons Learned Upgrading Harvest to Ruby 1.9.3 by Argorak on Tuesday April 17, 2012 @11:33AM (#3853039)
Yeah, but String#each_line was already present in Ruby 1.8, why didn't you use this in the first place? Much clearer meaning and still available. #each is pretty neutral.