I saw this operator in HAML code. I wonder what it is for.
I see the following works:
> ?{
=> "{"
> ?s
=> " "
> ?a
=> "a"
And this doesn't work:
> ?ab
SyntaxError: (irb):4: syntax error, unexpected '?'
So I suppose that it takes a character a argument and returns a string with that character.
questions:
- What does this operator do?
- When should one use it?
- If it really only creates a one-character string, why was it included in the language? Doesn't it break the language orthogonality? What is the benefit?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…