Project

General

Profile

Actions

Feature #8168

closed

Feature request: support for (single) statement lambda syntax/definition

Added by garysweaver (Gary Weaver) over 11 years ago. Updated almost 11 years ago.

Status:
Feedback
Target version:
-
[ruby-core:53742]

Description

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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0