What's the Point of the prefix ? operator in Ruby 1.9

前端 未结 3 1014
天涯浪人
天涯浪人 2020-12-12 05:25

I\'m just wondering what applications it has. I believe in 1.9 the prefix ? would return the string version of that character.

?a   #=> \"a\"
?\\t  #=>         


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-12 06:14

    in ruby 1.8 and earlier

    ?a 
    

    would return the ASCII version of 'a' char.

    in 1.9 it just returns the string ( just as you've assumed )

提交回复
热议问题