Project

General

Profile

Actions

Feature #7872

closed

`block_given?` does not work inside `define_method`

Added by alexeymuranov (Alexey Muranov) almost 12 years ago. Updated over 11 years ago.

Status:
Rejected
Target version:
[ruby-core:52309]

Description

=begin
Is this the expected behavior?

define_method :try do
block_given? ? yield : 'no block'
end

try { 'block' } # => "no block"

However:

def try_again
block_given? ? yield : 'no block'
end

try_again { 'block' } # => "block"

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0