0

Please help. I dont seem to understand blocks and methods well enough for even simple coding

https://code.sololearn.com/ciJa46dk5suT/?ref=app

8th Oct 2018, 4:46 AM
Conall O'Shannessy
Conall O'Shannessy - avatar
7 Answers
+ 3
method(){<start of scope/block variables/statements go here end of scope/block>}
8th Oct 2018, 6:03 AM
D_Stark
D_Stark - avatar
+ 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 =.
8th Oct 2018, 6:52 AM
Anna
Anna - avatar
+ 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
8th Oct 2018, 6:58 AM
Anna
Anna - avatar
+ 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
8th Oct 2018, 7:53 AM
Conall O'Shannessy
Conall O'Shannessy - avatar
+ 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.
8th Oct 2018, 7:57 AM
Conall O'Shannessy
Conall O'Shannessy - avatar
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
8th Oct 2018, 6:48 AM
Conall O'Shannessy
Conall O'Shannessy - avatar
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
8th Oct 2018, 6:55 AM
Conall O'Shannessy
Conall O'Shannessy - avatar