string - What does ?/ mean in Ruby? -
this question has answer here:
i stumbled across piece of code:
if source[0] != ?/ source = compute_asset_path(source, options) end
what's "?/
"? i've never seen writing strings way.
$ irb 2.0.0p247 :001 > ?/ => "/"
apparently works single characters only:
2.0.0p247 :001 > ?a => "a" 2.0.0p247 :002 > ?foo syntaxerror: (irb):2: syntax error, unexpected '?'
what ?
mean?
?
used represent single character string literals. ?a
,?b
not ?ab
.
to answer comment of op :
yes, are.
irb(main):001:0> ?x + 'y' => "xy" irb(main):002:0> 'x' + 'y' => "xy"
Comments
Post a Comment