What causes the error in the following code?
ruby -e "puts 1++"
-e:1: syntax error, unexpected $end
or
ruby -e "x=1; puts x++;"
-e:1: syntax error, unexpected ';'
What causes the error in the following code?
ruby -e "puts 1++"
-e:1: syntax error, unexpected $end
or
ruby -e "x=1; puts x++;"
-e:1: syntax error, unexpected ';'
Ruby doesn't have an ++
operator. You can do puts 1.next
though. Note that for your second example this would not change the value of x
, in that case you'd have to use x += 1
.