Project

General

Profile

Actions

Feature #7872

closed

`block_given?` does not work inside `define_method`

Added by alexeymuranov (Alexey Muranov) about 11 years ago. Updated almost 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