Issue #16898 has been updated by jackmaple (maple jack).


matz (Yukihiro Matsumoto) wrote in #note-3:
> "Ugliness is in the eye of the beholder". Could you explain why the current syntax is ugly?
> 
> In any case, if we change the syntax, all Ruby programs that use the current **ugly** lambda syntax no longer work. How do you think? Is it worth the pain of the whole Ruby community?
> 
> Matz.

Hello, we currently have lambda syntax, but at present-> seems to be just a simplified alternative,-> The braces behind can not be omitted when there is only one line of statement, or we can add a new lambda syntax, thank you.

----------------------------------------
Feature #16898: Modify the syntax of -> lambda expressions in ruby3
https://bugs.ruby-lang.org/issues/16898#change-85688

* Author: jackmaple (maple jack)
* Status: Open
* Priority: Normal
----------------------------------------
Hello ruby team.
Can we modify the syntax of lambda expressions in ruby3?
The current definition of lambda expression was added in ruby1.9, but this syntax looks too ugly.
``` ruby
lambda {|x| x + 1}   #This looks elegant.
#but...
-> x {x + 1}    #oh,no
-> x do x + 1 end  #this syntax looks too ugly
```
So are we going to abandon some historical issues? To modify -> lambda syntax?
It looks like this:
``` ruby
x -> x + 1
(x,y) -> x + y
x -> y -> x + y
x -> {
   x + 1
   x + 2
}
```
I think do..end or braces are only needed when there are multiple lines of code,lambda expression if there is only one statement should not need parentheses or do ... end block.
Thanks.



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

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>