WHat’s the error here?
a = [1,2,3]
if 1 in a
puts “exists”
end
It gives: test.rb:5: syntax error, unexpected keyword_end, expecting
$end
WHat’s the error here?
a = [1,2,3]
if 1 in a
puts “exists”
end
It gives: test.rb:5: syntax error, unexpected keyword_end, expecting
$end
Subject: error in if
Date: Tue 27 Nov 12 11:22:50PM +0900
Sorry for the delay!
Quoting Mohammed Yasin Rahman ([email protected]):
WHat’s the error here?
a = [1,2,3]
if 1 in a
puts “exists”
endIt gives: test.rb:5: syntax error, unexpected keyword_end, expecting $end
“if 1 in a” is not valid Ruby syntax.
A working line #3 could be
if(a.include?(1))
Carlo
There is no such construction in Ruby (were you thinking about another
language?) try something like
a = [1,2,3]
if a.include?(1)
puts “exists”
end
On 27 November 2012 14:22, Mohammed Yasin Rahman <
Yes, I was trying to code like python :). Now it’s okay. Thanks
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs