Discussion:
[ruby-list:50926] キーワード引数に self を使うとエラーにならない
小田 利通
2021-05-13 01:55:00 UTC
Permalink
$B%-!<%o!<%I0z?t$K(B $B5?;wJQ?t(B self $B$J$I$r;H$&$H!"%(%i!<$K$J$j$^$;$s!#(B

def f(self:10)
p self
end

f() #=> main

self $B$KBeF~$5$l$J$$$@$1$G$9$,!"%-!<%o!<%I$G$J$$2>0z?t$K(B self $B$r(B
$B;H$C$?>l9g$HF1$8$/%(%i!<$H$J$C$FM_$7$$$H;W$$$^$9!#(B

def g(self)
p self
end #=> syntax error

$ ruby --version #=> ruby 2.7.1p83

https://docs.ruby-lang.org/ja/latest/doc/spec=2fvariables.html#pseudo
$B5?;wJQ?t$NCM$rJQ99$9$k$3$H$O$G$-$^$;$s!#5<;wJQ?t$XBeF~$9$k$HJ8K!%(%i!<$K$J$j$^$9!#(B
T.Oda
Yukihiro Matsumoto
2021-05-13 02:05:58 UTC
Permalink
$B$^$D$b$H(B $B$f$-$R$m$G$9(B

$B$3$l$O;EMM$G$9!#<h$j=P$7$K$O(B binding.local_variable_get(:self) $B$r;H$$$^$9!#(B
$B$3$l$,D9$$$N$G(B _self $B$H$$$&L>A0$G;2>H$G$-$k$h$&$K$7$?$$$H$$$&%j%/%(%9%H$,=P$F$$$^$9!#(B

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


In message "Re: [ruby-list:50926] $B%-!<%o!<%I0z?t$K(B self $B$r;H$&$H%(%i!<$K$J$i$J$$(B"
Post by 小田 利通
$B%-!<%o!<%I0z?t$K(B $B5?;wJQ?t(B self $B$J$I$r;H$&$H!"%(%i!<$K$J$j$^$;$s!#(B
def f(self:10)
p self
end
f() #=> main
$B;H$C$?>l9g$HF1$8$/%(%i!<$H$J$C$FM_$7$$$H;W$$$^$9!#(B
def g(self)
p self
end #=> syntax error
$ ruby --version #=> ruby 2.7.1p83
https://docs.ruby-lang.org/ja/latest/doc/spec=2fvariables.html#pseudo
$B5?;wJQ?t$NCM$rJQ99$9$k$3$H$O$G$-$^$;$s!#5<;wJQ?t$XBeF~$9$k$HJ8K!%(%i!<$K$J$j$^$9!#(B
T.Oda
小田 利通
2021-05-13 02:15:18 UTC
Permalink
Post by Yukihiro Matsumoto
$B$3$l$O;EMM$G$9!#<h$j=P$7$K$O(B binding.local_variable_get(:self) $B$r;H$$$^$9!#(B
$B$"$j$,$H$&$4$6$$$^$9!#M}2r$7$^$7$?!#(B

$B;d8D?M$H$7$F$O!"J#;($J$N$O%$%d$J$N$G(B self $B$J$I$O6KNO;H$o$J$$$h$&$K$9$k$H;W$$$^$9!#(B

T.Oda


From: Yukihiro Matsumoto <***@ruby.or.jp>
Subject: [ruby-list:50927] Re: $B%-!<%o!<%I0z?t$K(B self $B$r;H$&$H%(%i!<$K$J$i$J$$(B
Date: Thu, 13 May 2021 11:05:58 +0900
Post by Yukihiro Matsumoto
$B$^$D$b$H(B $B$f$-$R$m$G$9(B
$B$3$l$O;EMM$G$9!#<h$j=P$7$K$O(B binding.local_variable_get(:self) $B$r;H$$$^$9!#(B
$B$3$l$,D9$$$N$G(B _self $B$H$$$&L>A0$G;2>H$G$-$k$h$&$K$7$?$$$H$$$&%j%/%(%9%H$,=P$F$$$^$9!#(B
https://bugs.ruby-lang.org/issues/17785
In message "Re: [ruby-list:50926] $B%-!<%o!<%I0z?t$K(B self $B$r;H$&$H%(%i!<$K$J$i$J$$(B"
Post by 小田 利通
$B%-!<%o!<%I0z?t$K(B $B5?;wJQ?t(B self $B$J$I$r;H$&$H!"%(%i!<$K$J$j$^$;$s!#(B
def f(self:10)
p self
end
f() #=> main
$B;H$C$?>l9g$HF1$8$/%(%i!<$H$J$C$FM_$7$$$H;W$$$^$9!#(B
def g(self)
p self
end #=> syntax error
$ ruby --version #=> ruby 2.7.1p83
https://docs.ruby-lang.org/ja/latest/doc/spec=2fvariables.html#pseudo
$B5?;wJQ?t$NCM$rJQ99$9$k$3$H$O$G$-$^$;$s!#5<;wJQ?t$XBeF~$9$k$HJ8K!%(%i!<$K$J$j$^$9!#(B
T.Oda
Loading...