Over a million developers have joined DZone.

Ruby Blocks Are Bad Designed.

·
I know I know its a feature not a bug! Now run away you stupid ruby fanbois!


def zork(up)
  puts 'foo'
  up.call(42)
  puts 'bar'
end
up = Proc.new do |n|
  return if n == 42
  puts 'foo'
end
zork(up)
#>>> foo
#>>> ... unexpected return (LocalJumpError)

def zork
  puts 'foo'
  up = Proc.new do |n|
    return if n == 42
    puts 'foo'
  end
  bla = up.call(42)
  puts 'bar'
end
zork
puts "baz"
#>>> foo
#>>> baz

def zork
  puts 'foo'
  up = lambda do |n|
    return if n == 42
    puts 'foo'
  end
  bla = up.call(42)
  puts 'bar'
end
zork
puts "baz"
#>>> foo
#>>> bar
#>>> baz
Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}