:foo
is a symbol named "foo". Symbols have the distinct feature that any two symbols named the same will be identical:
"foo".equal? "foo" # false
:foo.equal? :foo # true
This makes comparing two symbols really fast (since only a pointer comparison is involved, as opposed to comparing all the characters like you would in a string), plus you won't have a zillion copies of the same symbol floating about.
Also, unlike strings, symbols are immutable.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…