Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Ruby Blocks Are Bad Designed.

DZone's Guide to

Ruby Blocks Are Bad Designed.

· ·
Free Resource
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:

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}