This has absolutely nothing to do with variables.
:foo is a Symbol literal, just like 'foo' is a String literal and 42 is an Integer literal.
foo: is used in three places:
- as an alternative syntax for
Symbol literals as the key of a Hash literal: { foo: 42 } # the same as { :foo => 42 }
- in a parameter list for declaring a keyword parameter:
def foo(bar:) end
- in an argument list for passing a keyword argument:
foo(bar: 42)