るりまサーチ

最速Rubyリファレンスマニュアル検索!
158件ヒット [101-158件を表示] (0.012秒)
トップページ > クエリ:&[x] > クエリ:initialize[x]

別のキーワード

  1. _builtin &
  2. ipaddr &
  3. set &
  4. integer &
  5. nilclass &

検索結果

<< < 1 2 >>

Ruby用語集 (24.0)

Ruby用語集 A B C D E F G I J M N O R S Y

...参照演算子
: safe navigation operator
メソッド呼び出し構文においてレシーバーとメソッド名を結ぶ演算子の一つ「&.」。
「.」と違う点は、レシーバーが nil のとき引数の評価もメソッド呼び出しも行わずに nil を
返す、と...
...str.size」「user&.name」といったメソッド呼び出しにおける
「.」「&.」も演算子である。
「[*0..9]」におけるいわゆる splat 展開の * や、
Proc オブジェクトをブロックとして渡す「strs.map(&:length)」に
おける & も演算子であ...
...値を真偽値として用いる式。if、unless、while、until のあとなどに書かれる。

: 初期化
: initialize
オブジェクトが生成されるとき、initialize という名の private メソッドが
呼ばれる。このメソッドで行う処理をオブジェクトの...

rexml/parsers/streamparser (24.0)

ストリーム式の XML パーサ。

...exml/parsers/baseparser'
require 'rexml/parsers/streamparser'
require 'rexml/streamlistener'
class Listener
include REXML::StreamListener
def initialize
@events = []
end

def text(text)
@events << "text[#{text}]"
end

def tag_start(name, attrs)
@events << "tag_start[#{name}]"...
...oo="http://example.org/foo"
xmlns:bar="http://example.org/bar"><![CDATA[cdata is here]]>
<a foo:att='1' bar:att='2' att='&lt;'/>
&
amp;&amp; <!-- comment here--> &bar;
</root>
EOS

class Listener
def method_missing(name, *args)
p [name, *args]
end
def respond_to_missing?(sym, incl...
...=>"http://example.org/bar"}]
# >> [:cdata, "cdata is here"]
# >> [:text, "\n "]
# >> [:tag_start, "a", {"foo:att"=>"1", "bar:att"=>"2", "att"=>"<"}]
# >> [:tag_end, "a"]
# >> [:text, "\n && "]
# >> [:comment, " comment here"]
# >> [:text, " &bar;\n"]
# >> [:tag_end, "root"]
# >> [:text, "\n"]
//}...

tsort (24.0)

tsort はトポロジカルソートと強連結成分に関するモジュールを提供します。

...== Example

//emlist[][ruby]{
require 'tsort'

class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(node, &block)
fetch(node).each(&block)
end
end

{1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort
#=> [3, 2, 1, 4]

{1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_connected_comp...
...たツールは以下のように実装できます。

//emlist[][ruby]{
require 'tsort'

class Make
def initialize
@dep = {}
@dep.default = []
end

def rule(outputs, inputs=[], &block)
triple = [outputs, inputs, block]
outputs.each {|f| @dep[f] = [triple]}
@dep[triple] =...
...= nil ||
inputs_time != nil && outputs_time <= inputs_time
sleep 1 if inputs_time != nil && inputs_time.to_i == Time.now.to_i
block.call
end
end
}
end

def tsort_each_child(node, &block)
@dep[node].each(&block)
end
include TSort
end

def...

演算子式 (18.0)

演算子式 * assign * selfassign * multiassign * range * range_cond * and * or * not * cond

...-(単項)
* / %
+ -
<< >>
&

| ^
> >= < <=
<=> == === != =~ !~
&
&
||
.. ...
?:(条件演算子)...
...」「低い」は演算子の優先順位です。
例えば「&&」は「||」より優先順位が高いので、以下のように
解釈されます。

//emlist[][ruby]{
a && b || c #=> (a && b) || c
a || b && c #=> a || (b && c)
//}

ほとんどの演算子は特別な形式のメソッ...
...ての、式 2 から式 n までを
引数とする []= メソッド呼び出しに変換されます。

//emlist[例][ruby]{
class C
def initialize
@ary = [0,1,2,3,4,5,6,7]
end
def [](i)
@ary[i * 2]
end
def []=( i, v )
@ary[i * 2] = v
end
end
c = C.new
p c[3] # c.[]...

Proc.new -> Proc (12.0)

ブロックをコンテキストとともにオブジェクト化して返します。

...合、Ruby 2.7 では
$VERBOSE = true のときには警告メッセージ
「warning: Capturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。

ブロックを...
...しない呼び出しは推奨されていません。呼び出し元のメソッドで指定されたブロック
を得たい場合は明示的に & 引数でうけるべきです。

@raise ArgumentError スタック上にブロックがないのにブロックを省略した呼び出しを行っ...
...': tried to create Proc object without a block (ArgumentError)
# from -:2:in `foo'
# from -:4:in `<main>'
//}

Proc.new は、Proc#initialize が定義されていれば
オブジェクトの初期化のためにこれを呼び出します。このことを
除けば、Kernel.#proc と...

絞り込み条件を変える

Proc.new { ... } -> Proc (12.0)

ブロックをコンテキストとともにオブジェクト化して返します。

...合、Ruby 2.7 では
$VERBOSE = true のときには警告メッセージ
「warning: Capturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。

ブロックを...
...しない呼び出しは推奨されていません。呼び出し元のメソッドで指定されたブロック
を得たい場合は明示的に & 引数でうけるべきです。

@raise ArgumentError スタック上にブロックがないのにブロックを省略した呼び出しを行っ...
...': tried to create Proc object without a block (ArgumentError)
# from -:2:in `foo'
# from -:4:in `<main>'
//}

Proc.new は、Proc#initialize が定義されていれば
オブジェクトの初期化のためにこれを呼び出します。このことを
除けば、Kernel.#proc と...
<< < 1 2 >>