Project

General

Profile

Actions

Feature #13630

closed

:[] method should accept block in nice syntax

Added by khoan (khoa nguyen) almost 7 years ago. Updated over 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:81559]

Description

# given
module Bam
  def self.[](bam)
    yield bam
  end
end

# SyntaxError: unexpected keyword_do_block
Bam['bam'] do |b|
  puts b
end

# SyntaxError: unexpected { arg, expecting end-of-input
Bam['bam'] { |b|
  puts b
}

# Valid but more verbose
Bam.[]('bam') do |b|
  puts b
end

Bam.[]('bam') { |b|
  puts b
}
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0