ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: matz@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:82998] [Ruby trunk Feature#13630] :[] method should accept block in nice syntax
Date: Mon, 25 Sep 2017 13:31:58 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-66907.20170925133156.6daa059540aca052@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-13630.20170603122409@ruby-lang.org

Issue #13630 has been updated by matz (Yukihiro Matsumoto).


And now mruby does too.

Matz.


----------------------------------------
Feature #13630: :[] method should accept block in nice syntax
https://bugs.ruby-lang.org/issues/13630#change-66907

* Author: khoan (khoa nguyen)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
~~~ ruby
# 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
}
~~~



-- 
https://bugs.ruby-lang.org/

      parent reply	other threads:[~2017-09-25 13:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-13630.20170603122409@ruby-lang.org>
2017-06-03 12:24 ` [ruby-core:81559] [Ruby trunk Feature#13630] :[] method should accept block in nice syntax huukhoanguyen
2017-06-03 16:39 ` [ruby-core:81564] " shevegen
2017-08-31  5:25 ` [ruby-core:82544] " nobu
2017-09-25 12:18 ` [ruby-core:82988] [Ruby trunk Feature#13630][Closed] " shyouhei
2017-09-25 13:31 ` matz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-66907.20170925133156.6daa059540aca052@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).