I thought my old copy of SAMS TY Ruby in 21 Days, even though it assumes Ruby 1.7, was going to be good enough to get me started, but now I’m a little closer to thinking I might have to (horror of horrors) pay for a real book.
The book claims that
s = "AaBbCc 012"
s[0]
will return 65. When I, with Ruby 2.7 installed, try this in an irb session,
s[0]
unsurprisingly returns “A”. Was it the case that Ruby 1.7 would’ve returned the ASCII value, or are the authors way off track regardless?
Another claim they make is that if
footwear = “blue suede shoes”
footwear[“suede”]
footwear[“blue”] = “red”
footwear[“socks”] = “sandals”
…that the second line would just return “suede”, which it did, that the third line would cause footwear to equal “red suede shoes”, which it did, the last line wouldn’t return an error; would instead just leave the footwear string unaffected. But when I tried it in irb I got a multiline error message ending with “IndexError (string not matched)”
Is it true that attempting to index a nonexistent substring didn’t cause any errors in Ruby until later versions?
(And - since I think I know where this is all going anyway - what’s a good book to get started with contemporary Ruby? I’ve heard that O’Reilly’s Learning Ruby is actually well below the usual O’Reilly standard : / )