jgorset / facebook-messenger

Definitely the best way to make Bots on Facebook Messenger with Ruby
MIT License
962 stars 211 forks source link

Returning early #217

Closed abury closed 6 years ago

abury commented 6 years ago

Hey team

So, I feel like this is a stupid question, but how do you return early from within a block in the bot? When we use return we get the following exception:

LocalJumpError · unexpected return

I feel like this is happening because of a misunderstanding I have of basic ruby. Should we be using exit or break instead?

Thanks, Aron

jgorset commented 6 years ago

Hi @abury! Yeah, break sounds about right. This is relevant to your interests: https://makandracards.com/makandra/46939-ruby-a-small-summary-of-what-return-break-and-next-means-for-blocks

abury commented 6 years ago

Hey @jgorset

I tried break but was still getting a local jump error: unexpected break

next seems to do the trick 👍