< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事(スレッド移動)
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
Issue #16746 has been updated by mame (Yusuke Endoh).
https://github.com/ruby/ruby/pull/3479
----------------------------------------
Feature #16746: Endless method definition
https://bugs.ruby-lang.org/issues/16746#change-87306
* Author: mame (Yusuke Endoh)
* Status: Closed
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
----------------------------------------
Ruby syntax is full of "end"s. I'm paranoid that the ends end Ruby. I hope Ruby is endless.
So, I'd like to propose a new method definition syntax.
```ruby
def: value(args) = expression
```
As you see, there is no "end".
Examples.
```ruby
def: hello(name) =
puts("Hello, #{ name }")
hello("endless Ruby") #=> Hello, endless Ruby
```
```ruby
def: inc(x) = x + 1
p inc(42) #=> 43
```
```ruby
x = Object.new
def: x.foo = "FOO"
p x.foo #=> "FOO"
```
```ruby
def: fib(x) =
x < 2 ? x : fib(x-1) + fib(x-2)
p fib(10) #=> 55
```
Limitations.
* `def: foo x = x` is invalid; the parentheses for formal arguments are mandatory.
* `private def: foo = x` is invalid; this method definition cannot be an method argument.
A patch is attached. No conflicts.
---Files--------------------------------
endless-method-definition.patch (2.47 KB)
--
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>