0
Please help. I dont seem to understand blocks and methods well enough for even simple coding
7 Respuestas
+ 3
method(){<start of scope/block
variables/statements go here
end of scope/block>}
+ 2
Use it like this:
if answer == "no"
puts "boo"
else
puts "yay"
end
Make sure to use the comparison operator ==, not the assignment operator =.
+ 2
I don't know what #{answer} is, doesn't look like Ruby to me (but I haven't worked with Ruby for months). If you just use answer, it works
+ 1
I got it from here https://learnrubythehardway.org/book/ex11.html
but it looks like I don't fully understand its use and purpose.
thanks for your help
+ 1
Oh, I understand now. #{} is a placeholder to insert an input from gets to a string.
I used it incorrectly thinking it was needed every time an input was used.
It's all coming together.
0
thanks for the answer. I can get things to work when I only need one action plus a puts. but when I want to do ifs and else's i get lost. especially when the ifs and else's rely on a gets
0
hi Anna
I had tried both. either way it still outputs both "boo" and "yay" regardless of the answer given.
I've included your change in the code now.
thanks