Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
oezi
51 days ago
|
parent
|
context
|
favorite
| on:
Ruby Blocks
You are right on return (use next in a block), but break uses block scope.
judofyr
51 days ago
[–]
Maybe I explained it a bit imprecise. I was trying to explain the following behavior:
def foo p 1 yield p 2 end foo { break }
This only prints "1" because the break stops the execution of the invoked method (foo).
Mystery-Machine
51 days ago
|
parent
[–]
WAT? I'm a 12+ years Ruby developer and I didn't know this.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: