I am very new to Ruby and trying to run a script ,When I am trying to run a Ruby script like below, I am getting
> ruby test.rb
test.rb:53: syntax error, unexpected ':', expecting ')'
All::Config.new_global_config(domain: domain, realm: realm)
^
test.rb:53: syntax error, unexpected ':', expecting '='
All::Config.new_global_config(domain: domain, realm: realm)
When I see ruby version, it says:
> ruby -version
ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux]
-e:1: undefined local variable or method `rsion' for main:Object (NameError)
Any pointers? Is it because of the version? 1.8.x instead of 1.9 or more?
The {key: 'value'}
syntax was added in ruby v1.9
. To do this in v1.8
, you need to use the {:key => 'value'}
syntax (which is still valid in modern ruby, too).
1.8
and 1.9
are both very old versions!!! Neither has been supported for a long time. (1.8 was retired in 2013; 1.9 in 2015.)
The latest version, at the time of writing this, is 2.4.1
. Use this if possible.
The oldest supported version of ruby is 2.2.7
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With