Arnob Arnob - 4 months ago 12
Ruby Question

Why I'm getting void value expression although I have assigned value

I am new into ruby. I have the following code block:

a = 10

while a < 20 do
puts "True"
a++

next unless a == 12
puts "This is not 12"
end


$end


However, I'm getting void value expression for
a ==12
.I have assigned 10 into it to begin with so I don't see why I'm getting void value.

Answer

replace a++ by a += 1 should work.

Ruby has no ++ operator. No increment operator (++) in Ruby?