From: Michael Libby Date: 2008-11-23T01:09:31+09:00 Subject: Re: Need help understand an expression On Sat, Nov 22, 2008 at 9:35 AM, Buzz Hill wrote: > Hi, > > > Can someone explain the role of the "?" before the "x" > > s = "abcdefg" > s[0] = ?x # s == "xbcdef" > > > I know this will accomplish the same thing. > > s[0] = 'x' irb(main):004:0> ?a => 97 It's an integer value keyword. http://ruby-doc.org/docs/ProgrammingRuby/html/language.html has more information under "Integer and Floating Point Numbers" irb(main):005:0> x = " " => " " irb(main):006:0> x[0] = ?a => 97 irb(main):007:0> x => "a" End result for the string you modify is the same because String#[]= with a single integer index accepts either integers or strings. irb(main):002:0> x[0] = 'abc' => "abc" irb(main):003:0> x => "abc" -Michael Libby