From: "garysweaver (Gary Weaver)" Date: 2013-04-12T04:11:29+09:00 Subject: [ruby-core:54191] [ruby-trunk - Feature #8168] Feature request: support for (single) statement lambda syntax/definition Issue #8168 has been updated by garysweaver (Gary Weaver). Thinking about it a bit more, I guess it would have to be context sensitive. Just some character that is parsed when the block is being parsed that indicates that the following statement is a block. So maybe the best that could be done without a lot of overhead is whitespace between it, the method, and the block. Then you just need to pick a good operator. I don't like the smiley here, but the world needs more smiles, so here it is for an example: some_method :some, :args, :here, -> :) expression Then you could also do: def hello :) puts "hello world" A single character that doesn't have many pixels like a colon would be best/most readable: def hello : puts "hello world" but colon is used by itself already in the ternary/conditional operator ?: (i.e., a ? b : c) so that might be confusing. Equals might look too much like an assignment: def hello = puts "hello world" I wish colon would work, because it would be a lot nicer-looking. def a: b; def b: c; def c: d; That just looks nice! :) ---------------------------------------- Feature #8168: Feature request: support for (single) statement lambda syntax/definition https://bugs.ruby-lang.org/issues/8168#change-38468 Author: garysweaver (Gary Weaver) Status: Feedback Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: Abstract: Proposal for single statement lambda support, either via a new type of stab '->>', such that '->> some value;' would be equivalent to '-> {some value;}', or by just supplying a stab operator '->' with a value instead of a block (which would be more intuitive). Background: Often proc and lambda blocks are one statement long. Braces or do/end in this case are mostly unnecessary and result in less beautiful code Pros: may reduce amount of syntax required, especially if can re-use same operator. Cons: different stab operator may be confusing because of similarity to existing lambda operator. With either proposal, may cause additional overhead for interpreters. -- http://bugs.ruby-lang.org/