キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) -
NEWS for Ruby 2
. 1 . 0 (12) -
NEWS for Ruby 2
. 2 . 0 (11) -
NEWS for Ruby 2
. 3 . 0 (10) -
NEWS for Ruby 2
. 5 . 0 (8) -
NEWS for Ruby 2
. 6 . 0 (7) -
NEWS for Ruby 2
. 7 . 0 (6) -
NEWS for Ruby 3
. 0 . 0 (5) - Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (12)
- Rubyの起動 (4)
-
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 4 feature (12) -
ruby 1
. 9 feature (12) - オブジェクト指向スクリプト言語 Ruby リファレンスマニュアル (12)
- クラス/メソッドの定義 (12)
- セキュリティモデル (12)
- プログラム・文・式 (12)
- メソッド呼び出し(super・ブロック付き・yield) (12)
- 制御構造 (12)
- 手続きオブジェクトの挙動の詳細 (12)
- 正規表現 (12)
検索結果
先頭5件
-
メソッド呼び出し(super・ブロック付き・yield) (3059.0)
-
メソッド呼び出し(super・ブロック付き・yield) * super * block * yield * block_arg * numbered_parameters * call_method
...メソッド呼び出し(super・ブロック付き・yield)
* super
* block
* yield
* block_arg
* numbered_parameters
* call_method
//emlist[例][ruby]{
foo.bar()
foo.bar
bar()
print "hello world\n"
print
Class.new
Class::new
//}
文法:
[式 `.'] 識別子 [`(' [[`*']......p b # => "b"
}
//}
===[a:call_method] .() および ::() 形式のメソッド呼び出し(callメソッドの糖衣構文)
下記はcallメソッドの糖衣構文です。
Proc#callにも言及がありますが、Proc以外のオブジェクトに対しても(callメソッドさえ定義......されていれば)使えます。
//emlist[例][ruby]{
foo.(100) # foo.call(100)と全く同じ意味
foo::(100) # foo.call(100)と全く同じ意味
//}
文法:
式 `.' `(' [[`*'] 式] ... [`&' 式] `)'
式 `::' `(' [[`*'] 式] ... [`&' 式] `)'... -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (61.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]......=> ruby 1.8.0 (2003-06-21) [i586-linux]
[1, 2, nil]
Proc.new { break }.call
=> ruby 1.6.8 (2002-12-24) [i586-linux]
=> -:1:in `call': break from proc-closure (LocalJumpError)
from -:1
ruby 1.......い。
break は実行を中断する。
lambda {|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... -
手続きオブジェクトの挙動の詳細 (61.0)
-
手続きオブジェクトの挙動の詳細 * def * should_use_next * block * lambda_proc * orphan
...Proc.new { var }
var = 2
def foo
$foo.call
end
p foo # => 2
//}
===[a:should_use_next] 手続きを中断して値を返す
手続きオブジェクトを中断して、呼出し元(呼び出しブロックでは yield、それ以外では Proc#call)
へジャンプし値を返すには n......せん。
//emlist[例][ruby]{
def foo
f = Proc.new{
next 1
2 # この行に到達することはない
}
end
p foo().call #=> 1
//}
===[a:block] Proc オブジェクトをブロック付きメソッド呼び出しに使う
ブロック付きメソッドに対し......y]{
b = Proc.new{|a,b,c|
p a,b,c
}
b.call(2, 4)
#=> 2
4
nil
//}
//emlist[lambda は引数の数が違うとエラーになる][ruby]{
b = lambda{|a,b,c|
p a,b,c
}
b.call(2, 4)
#=> wrong number of arguments (2 for 3) (ArgumentError)
//}
d:spec/call#block_arg も参照してください......uby]{
b = Proc.new{|a,b,c|
p a,b,c
}
b.call(2, 4)
#=> 2
4
nil
//}
//emlist[lambda は引数の数が違うとエラーになる][ruby]{
b = lambda{|a,b,c|
p a,b,c
}
b.call(2, 4)
# => wrong number of arguments (given 2, expected 3)
//}
d:spec/call#block_arg も参照してください... -
NEWS for Ruby 3
. 0 . 0 (49.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ocs
accepting a single rest argument and no keywords.
16166
//emlist[][ruby]{
pr = proc{|*a, **kw| [a, kw]}
pr.call([1])
# 2.7 => [[1], {}]
# 3.0 => [[[1]], {}]
pr.call([1, {a: 1}])
# 2.7 => [[1], {:a=>1}] # and deprecation warning
# 3.0 => a=>1}, {}]
//}
* Arguments forwarding (`...`)......== Core classes updates
Outstanding ones only.
* Array
* The following methods now return Array instances instead of subclass instances when called on subclass instances: 6087
* Array#drop
* Array#drop_while
* Array#flatten
* Array#slice!
* Array#slice / Array#[......ata2', '--', 'data3']
dirty_data[(1..).step(2)] # take each second element
# => ["data1", "data2", "data3"]
//}
* Binding
* Binding#eval when called with one argument will use `"(eval)"` for `__FILE__` and `1` for `__LINE__` in the evaluated code. 4352 17419
* ConditionVariable
* Condit... -
ruby 1
. 6 feature (49.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...-:9: warning: p (...) interpreted as method call
ruby 1.6.5 (2001-09-19) [i586-linux]
Bar
[1, 2, 3]
Bar
Array
Array
Array
=> -:9: warning: p (...) interpreted as method call
ruby 1.6.5 (2001-10-05) [i586-......e Foo
def foo
:foo
end
end
class Bar
include Foo
end
m = Foo.instance_method :foo
p m.bind(Bar.new).call
=> ruby 1.6.4 (2001-06-04) [i586-linux]
-:12:in `bind': first argument must be an instance of Foo (TypeError)
from -:12......v'
p Resolv.new.getaddress("www.ruby-lang.org").to_s
=> /usr/local/lib/ruby/1.6/resolv.rb:160: warning: timeout (...) interpreted as method call
/usr/local/lib/ruby/1.6/resolv.rb:55: warning: instance variable @initialized not initialized
/usr/local/lib/ruby/1.6/resolv.rb:113:... -
ruby 1
. 8 . 4 feature (49.0) -
ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。
...)
* ((<ruby 1.8.4 feature/mkmf: find_executable() [compat]>))
* ((<ruby 1.8.4 feature/拡張ライブラリAPI>))
* ((<ruby 1.8.4 feature/rb_funcall2() [bug]>))
* ((<ruby 1.8.4 feature/rb_respond_to() [change]>))
* ((<ruby 1.8.4 feature/rb_obj_respond_to() [new]>))
* ((<ruby 1.8.4 feature/......cted '(', expecting $end
#Tue Nov 1 14:20:11 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
#
# * eval.c (rb_call_super): should call method_missing if super is
# called from Kernel method.
#
# * eval.c (exec_under): frame during eval should preserve external
# informat......サンプル兼ライブラリ
#Wed Dec 7 01:02:04 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
#
# * ext/tk/README.macosx-aqua: [new document] tips to avoid the known
# bug on platform specific dialogs of Tcl/Tk Aqua on MacOS X.
MacOS X 上で Aqua 版の Tcl/Tk を用いた... -
NEWS for Ruby 2
. 7 . 0 (37.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...なりました。 15958
* UnboundMethod
* 新規メソッド
* UnboundMethod#bind_callが追加されました。 15955
* 「umethod.bind_call(obj, ...)」は「umethod.bind(obj).call(...)」と
同じ意味です。
このイディオムはいくつかのライ......o
def add_1(x) # override
x + 2
end
end
obj = Bar.new
p obj.add_1(1) #=> 3
p Foo.instance_method(:add_1).bind(obj).call(1) #=> 2
p Foo.instance_method(:add_1).bind_call(obj, 1) #=> 2
//}
* Warning
* 新規メソッド
* Warning.[] とWarning.[]=がいくつかのカテゴリ化......opts.on("-b", "--bar", "bar") {|v| }
opts.on("-c", "--baz", "baz") {|v| }
end.parse!
//}
//emlist{
$ ruby test.rb --baa
Traceback (most recent call last):
test.rb:7:in `<main>': invalid option: --baa (OptionParser::InvalidOption)
Did you mean? baz
bar
//}
* Pathname
* Pa... -
クラス/メソッドの定義 (37.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...合のブロック引数の値はnilです。
//emlist[例][ruby]{
def foo(cnt, &block_arg)
cnt.times { block_arg.call } # ブロックに収まったProcオブジェクトはcallで実行
end
foo(3) { print "Ruby! " } #=> Ruby! Ruby! Ruby!
//}
メソッド定義において、仮引数はその......ven?
Proc.new.call(1,2) # proc.call(1,2) でも同じ(proc は組み込み関数)
end
end
# 応用: 引数として Proc オブジェクトとブロックの
# 両方を受け付けるイテレータを定義する例
def foo(pr = nil, &block)
pr = pr || block
pr.call(1,2)
end
foo(proc......{|a,b| p [a,b]})
foo {|a,b| p [a,b]}
# ブロック引数を使う
def baz(&block)
if block
block.call(1,2)
end
end
//}
またメソッド実行時の例外を捕捉するために begin 式と同様
のrescue, else, ensure 節を指定できます。
例外処理についてはd:spec/con... -
NEWS for Ruby 2
. 2 . 0 (31.0) -
NEWS for Ruby 2.2.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...2以前は読み込みモードで開いていました。
=== 標準添付ライブラリの更新 (優れたもののみ)
* continuation
* callcc は廃止されました。Fiberを使ってください。
* digest
* Kernel.#Digest はスレッドセーフになりました。......acement.
* rb_thread_blocking_region_begin -> rb_thread_call_without_gvl family
* rb_thread_blocking_region_end -> rb_thread_call_without_gvl family
* TRAP_BEG -> rb_thread_call_without_gvl family
* TRAP_END -> rb_thread_call_without_gvl family
* rb_thread_select -> rb_thread_fd_......internal function. no replacement.
* rb_run_exec_options_err : internal function. no replacement.
* rb_thread_blocking_region -> rb_thread_call_without_gvl family
* rb_thread_polling -> rb_thread_wait_for
* rb_big2str0 : internal function. no replacement.
* rb_big2ulong_pack ->... -
ruby 1
. 9 feature (31.0) -
ruby 1.9 feature ruby version 1.9.0 は開発版です。 以下にあげる機能は将来削除されたり互換性のない仕様変更がなされるかもしれません。 1.9.1 以降は安定版です。 バグ修正がメインになります。
...lk:197512>))
=== 2006-06-13
: IPsocket
: TCPsocket
: SOCKSsocket
: TCPserver
: UDPsocket
: UNIXsocket
: UNIXserver
削除
=== 2006-06-11
: __callee__ [new]
: __method__ [new]
((<URL:http://www.dm4lab.to/~usa/ruby/d/200606a.html#id20060610_P1_7>))
: Symbol#to_proc
=== 2006-06-10
* 新機......chomp [obsolete]
: chomp! [obsolete]
: split [obsolete]
: scan [obsolete]
削除
=== 2005-10-21
: funcall [new]
fcall から改名
: Module#instance_exec [new]
: Module#module_exec [new]
追加
=== 2005-09-16
: ((<Dir/Dir.glob>)) [compat]
: ((<D......同様のことはできます。
p Dir.glob("f*\0b*") # => ["foo", "bar"]
p Dir.glob("{f*,b*}") # => ["foo", "bar"]
=== 2005-09-05
: fcall [new]
追加
=== 2005-08-30
: Object#send, Object#__send__ [ruby][change]
レシーバを指定した呼び出しではprivateメソッドを...