別のキーワード
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) -
ruby 1
. 6 feature (11)
検索結果
-
クラス/メソッドの定義 (15043.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...クラス/メソッドの定義
* クラス/メソッドの定義:
* class
* singleton_class
* module
* method
* operator
* nest_method
* eval_method
* singleton_method
* class_method
* limit
* 定義に関する操作:
* alias
* undef
* d......ef foo(x, y = 1) # 2番目の引数yにデフォルト値を指定
10 * x + y
end
p foo(1, 5) #=> 15
p foo(3) #=> 31
p foo #=> ArgumentError (wrong number of arguments)
//}
デフォルト値を指定する引数の位置は、1つの連続した区間になっている必要があ......ソッド定義式やinstance_eval)でのみ呼び出せ
ます。
//emlist[例: protected の可視性][ruby]{
class Foo
def foo
p caller.last
end
protected :foo
end
obj = Foo.new
# そのままでは呼べない
obj.foo rescue nil # => -:11 - protected method `foo' called for #<F... -
ruby 1
. 6 feature (66.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...$; が有効にな
るのは引数省略時だけでした。
$; = ":"
p "a:b:c".split(nil)
=> -:2:in `split': bad separator (ArgumentError)
from -:2
ruby 1.6.7 (2002-03-01) [i586-linux]
=> ruby 1.6.7 (2002-07-30) [i586-linux]
["a", "b", "c"]
: 2002-06......p Marshal.dump(Object.new).unpack("CC").join(".")
=> ruby 1.6.4 (2001-06-11) [i586-linux]
"4.6"
: $SAFE / ((<クラス/メソッドの定義/def>))
doc/NEWS には
Fixed so defining a new method is allowed under $SAFE == 4, which
previously wasn't.
とある......Tue Jun 5 15:16:06 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_add_method): should not call rb_secure(), for
last_func may not be set.
差分は以下のようです。
@@ -227,10 +227,7 @@ rb_add_method(klass, mid, node, noex)
NODE *bo... -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (54.0) -
1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))
...い。break が例外になる。
Proc.new {|a,b,c| p [a,b,c]}.call(1,2)
=> -:1: wrong # of arguments (2 for 3) (ArgumentError)
from -:1:in `call'
from -:1
ruby 1.6.8 (2002-12-24) [i586-linux]......(C の do ... while 構文と同じ)をしていませんでした。
((<ruby-list:34618>))
: ((<"rescue/ensure on class/module"|クラス/メソッドの定義/クラス定義>)) [compat]
メソッド定義のほかにもクラス定義やモジュール定義にもrescue/ensureを
つけ......irst>)) [compat]
: ((<Array#last|Array/last>)) [compat]
省略可能な引数を追加
: ((<Array#push|Array/push>)) [compat]
: ((<Array#unshift|Array/unshift>)) [compat]
: ((<Array#insert|Array/insert>)) [compat]
引数が指定されない場合に、ArgumentError 例外が発生しなく...