Conditional return

I don't know whether this is the right forum, but it says Ruby in the title... anyway, I'm trying to move ahead in my lessons at Code School.

search = "Contra"
games = ["Super Mario Bros.", "Contra", "Metroid", "Mega Man 2"]
search_index = games.find_index(search)
if search_index
  search_result = "Game #{search} found: #{games[search_index]} at index #{search_index}."
else
  search_result = "Game #{search} not found."
end
puts search_result
After editing the above code, I get a message saying I didn't remove the variable assignment in the "if" statement. What's the variable assignment here, so I can remove it?
That code works, so I'm not sure what it's saying is wrong. Maybe it's looking for you to do something different, but without seeing the lesson itself I'm not sure.
I don't suppose you'd be willing to start a Code School account? No sense in posting a screenshot, then getting in trouble for it.
Sure, one moment.
Thank you very much, Trihan.
How far into this do I have to go to get to that bit?
It's in the 'Ruby Bits' course, first level. You can skip the first few lesson and go right to "condition return 1".
Ah, I see. In Ruby you can set a variable to the result of an expression, so it's asking you to set search_result to the result of the if statement and directly using strings, rather than setting the variable inside the if.

Code:
search = "Contra"games = ["Super Mario Bros.", "Contra", "Metroid", "Mega Man 2"]search_index = games.find_index(search)search_result = if search_index  "Game #{search} found: #{games[search_index]} at index #{search_index}."else  "Game #{search} not found."endputs search_result
Did it say you had the right answer? It's giving me the same old story.
Yeah, that was right on mine. Did you take out the "search_result =" in the else as well?
Now I have. Thanks; you just saved me hours of frustration.
Any time! Let me know if you have any further issues.
You do know you could literally just put puts in front of that right?

Code:
name     = 'Contra'_, index = ["Super Mario Bros.", "Contra", "Metroid", "Mega Man 2"].each_with_index.find { |g| g == name }puts if   "Game #{name} found: #{name} at index #{index}."else  "Game #{name} not found."end

Original thread: https://forums.rpgmakerweb.com/threads/conditional-return.39796/