I'd hazard a guess that the reasoning is because the '+' behavior was
confusing and potentially surprising. Pathname defines '+' as a filename
join, so Pathname('/foo') + Pathname('bar') == Pathname('/foo/bar'). But
'/foo' + Pathname('bar') == '/foobar'. This is surprising and bug-prone if
you have code that mixes pathnames and strings.I'd recommend sticking to interpolation for pathname/string concatenation; then it doesn't matter which object is what. On Sep 12, 2012 11:06 PM, "Jonathan Tran" <[email protected]> wrote: > It's definitely a judgment call. Not sure if this helps you, but I think > most people use string interpolation, which calls #to_s implicitly. So I > think this would work just fine in 1.9: > > require "pathname" > f = Pathname("howdy") > p "well #{f}" > > > The use cases are like this: > > > > require "pathname" > > f = Pathname("howdy") > > p ("well " + f) > > > > Under 1.8.7 that's "well howdy". Under 1.9.3 it's an error, "can't > > convert Pathname into String." One wants to say: "Sure you can, just > > call to_s like you used to!" > > > > It's the breakage I don't understand. Why do our Benevolent Masters > > think this is just okay? I'll never find all the code where I'm doing > > this sort of thing... m. > > -- > Posted via http://www.ruby-forum.com/. > > -- You received this message because you are subscribed to the Google Groups ruby-talk-google group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at https://groups.google.com/d/forum/ruby-talk-google?hl=en
