Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How are `:~@` and `:!@` parsed?

When I write :~@ and :!@, they are evaluated to :~ and :!, which can be achieved also by writing :~ and :!. How are these expressions parsed, and where did the @ go?

like image 403
sawa Avatar asked Oct 31 '14 19:10

sawa


1 Answers

It's to do with precedence in the parser. A simple dash defeats the colon-means-a-symbol syntax, too:

2.1.2 :004 > c = :test-thing
NameError: undefined local variable or method `thing' for main:Object

It's easy enough to work around it, though: try :'~@',

(Of course, if you can avoid creating such a weird symbol in your code, that might be a better idea...)

like image 53
Andy Jones Avatar answered Oct 07 '22 01:10

Andy Jones