551件ヒット
[1-100件を表示]
(0.023秒)
ライブラリ
- ビルトイン (206)
-
cgi
/ core (11) - csv (33)
- dbm (11)
- gdbm (11)
- json (22)
- matrix (12)
- monitor (11)
- ostruct (11)
- pstore (11)
- rake (11)
-
rexml
/ document (11) -
rinda
/ tuplespace (11) -
rubygems
/ config _ file (11) - sdbm (11)
-
win32
/ registry (22) - win32ole (22)
-
yaml
/ dbm (22)
クラス
- Array (19)
-
CSV
:: Row (22) -
CSV
:: Table (11) - DBM (11)
- Enumerator (22)
- GDBM (11)
-
Gem
:: ConfigFile (11) - Hash (77)
-
JSON
:: State (22) -
ObjectSpace
:: WeakMap (11) - OpenStruct (11)
- PStore (11)
-
REXML
:: Attributes (11) -
Rake
:: TaskArguments (11) -
Rinda
:: TupleEntry (11) - SDBM (11)
- String (11)
- Struct (11)
- Thread (22)
- Vector (12)
- WIN32OLE (11)
-
WIN32OLE
_ VARIANT (11) -
Win32
:: Registry (22) -
YAML
:: DBM (22)
モジュール
-
CGI
:: QueryExtension :: Value (11) - Kernel (11)
オブジェクト
- ENV (22)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - Hash (11)
- Marshal フォーマット (11)
- MonitorMixin (11)
-
NEWS for Ruby 3
. 1 . 0 (3) - []= (221)
- new (22)
-
next
_ values (11) - pack (19)
- pack テンプレート文字列 (11)
-
peek
_ values (11) -
rb
_ ary _ new (11) - rss (11)
-
ruby 1
. 8 . 3 feature (11) -
ruby 1
. 9 feature (11) - store (33)
- unpack (11)
- クラス/メソッドの定義 (11)
検索結果
先頭5件
-
CGI
:: QueryExtension :: Value # [](idx , *args) (21100.0) -
@todo
@todo -
Hash
. [](*key _ and _ value) -> Hash (18211.0) -
新しいハッシュを生成します。 引数は必ず偶数個指定しなければなりません。奇数番目がキー、偶数番目が値になります。
...ォルト値を指定することはできません。
Hash.newを使うか、Hash#default=で後から指定してください。
@param key_and_value 生成するハッシュのキーと値の組です。必ず偶数個(0を含む)指定しなければいけません。
@raise ArgumentError 奇......す。
(1) [キー, 値, ...] の配列からハッシュへ
//emlist[][ruby]{
ary = [1,"a", 2,"b", 3,["c"]]
p Hash[*ary] # => {1=>"a", 2=>"b", 3=>["c"]}
//}
(2) キーと値のペアの配列からハッシュへ
//emlist[][ruby]{
alist = [[1,"a"], [2,"b"], [3,["c"]]]
p alist.flatten(1) # => [......ュへ
//emlist[][ruby]{
keys = [1, 2, 3]
vals = ["a", "b", ["c"]]
alist = keys.zip(vals) # あるいは alist = [keys,vals].transpose
p alist # => [[1, "a"], [2, "b"], [3, ["c"]]]
p Hash[alist] # => {1=>"a", 2=>"b", 3=>["c"]}
//}
(4) キーや値が配列の場合
//emlist[][ruby]{
alist =... -
Hash
. [](other) -> Hash (18126.0) -
新しいハッシュを生成します。 引数otherと同一のキーと値を持つ新たなハッシュを生成して返します。
...//emlist[][ruby]{
h = {1 => "value"}
h.default = "none"
g = Hash[h]
p g #=> {1=>"value"}
p h[:no] #=> "none"
p g[:no] #=> nil
h[:add] = "some"
p h #=> {1=>"value", :add=>"some"}
p g #=> {1=>"value"}
h[1] << 'plus' #破壊的操作
p h #=> {1=>"valueplus", :add=>"some"}
p g #=> {1=>"valueplus"}
/... -
Rake
:: TaskArguments # [](key) -> object (18124.0) -
与えられたパラメータ名に対応する値を返します。
...の名前を指定します。
//emlist[][ruby]{
# Rakefile での記載例とする
task default: :test_rake_app
task :test_rake_app do
arguments = Rake::TaskArguments.new(["name1", "name2"], ["value1", "value2"])
arguments["name1"] # => "value1"
arguments["name2"] # => "value2"
end
//}... -
Thread
# value -> object (18119.0) -
スレッド self が終了するまで待ち(Thread#join と同じ)、 そのスレッドのブロックが返した値を返します。スレッド実行中に例外が 発生した場合には、その例外を再発生させます。
...結果を出力する例です。
threads = []
threads.push(Thread.new { n = rand(5); sleep n; n })
threads.push(Thread.new { n = rand(5); sleep n; n })
threads.push(Thread.new { n = rand(5); sleep n; n })
threads.each {|t| p t.value}
最後の行で、待ち合わせを行って......いることがわかりにくいと思うなら以下
のように書くこともできます。
threads.each {|t| p t.join.value}... -
JSON
:: State # [](name) -> object (18116.0) -
Return the value returned by method name.
...Return the value returned by method name.... -
Hash
# [](key) -> object | nil (18112.0) -
key に関連づけられた値を返します。
..."all"}
p h[:ab] #=> "some"
p h[:ef] #=> nil
h1 = Hash.new("default value")
p h1[:non] #=> "default value"
h2 = Hash.new {|*arg| arg}
p h2[:non] #=> [{}, :non]
//}
@see Hash.new, Hash#fetch,Hash#values_at,Hash#key?, Hash#default, Hash#default_proc... -
Win32
:: Registry # [](name , wtype = nil) (18112.0) -
@todo
...@todo
レジストリ値 name に value を書き込みます。
オプション引数 wtype を指定した場合は,その型で書き込みます。
指定しなかった場合,value のクラスに応じて次の型で書き込みます:
* Integer
REG_DWORD
* String
REG_SZ
*... -
Rinda
:: TupleEntry # [](key) (18106.0) -
タプルの key に対応する要素を返します。
...タプルの key に対応する要素を返します。
Rinda::TupleEntry#value[key] を返します。
@param key 要素を指定するキー
@see Rinda::TupleEntry#fetch... -
Thread
# [](name) -> object | nil (18106.0) -
name に対応したスレッドに固有のデータを取り出します。 name に対応するスレッド固有データがなければ nil を返し ます。
...>: C
//}
Thread#[] と Thread#[]= を用いたスレッド固有の変数は
Fiber を切り替えると異なる変数を返す事に注意してください。
//emlist[][ruby]{
def meth(newvalue)
begin
oldvalue = Thread.current[:name]
Thread.current[:name] = newvalue
yield
ensu......re
Thread.current[:name] = oldvalue
end
end
//}
この関数に与えるブロックがFiberを切り替える場合は動的スコープとしては
正しく動作しません。
//emlist[][ruby]{
f = Fiber.new {
meth(1) {
Fiber.yield
}
}
meth(2) {
f.resume
}
f.resume
p Thread.cu......rrent[:name]
# => nil if fiber-local
# => 2 if thread-local (The value 2 is leaked to outside of meth method.)
//}
Fiber を切り替えても同じ変数を返したい場合は
Thread#thread_variable_get と Thread#thread_variable_set
を使用してください。
@see Thread#fetch, Thread#[]=...