Ruby 1.8.7:
"abc"[0]
=> 65
Ruby 1.9*
"abc"[0]
=> "a"
Is there a way I can safely write the code above to produce the second result in both 1.8.7 and 1.9*? My solution so far is: "abc".split('').first but that doesn’t seem very clever.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
produces the 2nd result in both versions.
1.8: http://ruby-doc.org/core-1.8.7/Integer.html#method-i-chr
1.9: http://ruby-doc.org/core-1.9.3/String.html#method-i-chr