るりまサーチ

最速Rubyリファレンスマニュアル検索!
280件ヒット [1-100件を表示] (0.019秒)

別のキーワード

  1. format spec
  2. format spec=
  3. installer spec
  4. oldformat spec
  5. uninstaller spec

検索結果

<< 1 2 3 > >>

メソッド呼び出し(super・ブロック付き・yield) (26100.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
//}

文法:

[式 `.'] 識別子 [`(' [[`*']...
...のメソッドを持つオブジェクトのメソッド定義式内でなければ呼び出せ
ません。d:spec/def#limit を参照して下さい。

ハッシュ式の解説(d:spec/literal#hash)にも書かれている通り、
メソッド呼出の末尾にHashを渡す場合は {, } を省...
...略することができます。
これを用いることでキーワード引数を渡すことができます。
この Hash はd:spec/def#methodで解説されているキーワード引数に
分解されて引き渡されます。


===[a:super] super

//emlist[例][ruby]{
super
super(1,2,3)
/...
...略することができます。
これを用いることでキーワード引数を渡すことができます。
この Hash はd:spec/def#methodで解説されているキーワード引数に
分解されて引き渡されます。

メソッド呼び出しで `.' の代わりに `&.' を使う...

クラス/メソッドの定義 (23090.0)

クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined

...ァベットの大文字で始まる識別子です。

rescue/ensure 節を指定し、例外処理ができます。
例外処理についてはd:spec/control#begin参照。

クラス定義は、識別子で指定した定数へのクラスの代入になります
(Ruby では、クラスもオ...
...たオブジェクトには引き継がれません.

rescue/ensure 節を指定し、例外処理ができます。
例外処理についてはd:spec/control#begin参照。

特異クラス定義式は、最後に評価した式の結果を返します。最後に評価した式
が値を返さ...
...合のブロック引数の値はnilです。

//emlist[例][ruby]{
def foo(cnt, &block_arg)
cnt.times { block_arg.call } # ブロックに収まったProcオブジェクトはcallで実行
end
foo(3) { print "Ruby! " } #=> Ruby! Ruby! Ruby!
//}

メソッド定義において、仮引数はその...

手続きオブジェクトの挙動の詳細 (23066.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 も参照してください...

プログラム・文・式 (23042.0)

プログラム・文・式 * exp * terminate

...(1+2)*3
foo()
if test then ok else ng end

Ruby の式には、spec/variables、さまざまなspec/literal、それらの
spec
/operator、if や while などのspec/control、spec/call
spec
/defがあります。

式は括弧によってグルーピングすることがで...

制御構造 (23042.0)

制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END

...の右辺に置くと
syntax error になります)。

RubyはC言語やPerlから引き継いだ制御構造を持ちますが、
その他にd:spec/call#blockという
制御構造の抽象化を援助する機能があります。ブロック付きメソッド呼び出しは
繰り返しを始...
...e {a: 1, b: 2, c: 3}
in a: Integer => m
"matched: #{m}"
else
"not matched"
end
# => "matched: 1"
//}

パターンマッチ構文についてはspec/pattern_matchingで説明しています。

=== 繰り返し

====[a:while] while

//emlist[例][ruby]{
ary = [0,2,4,8,16,32,64,128,256,512,1024]...
...数で指定された例外を、第二引数をメッセージとして発生さ
せます。第四の形式の第三引数は
$@または
Kernel.#callerで得られる
スタック情報で、例外が発生した場所を示します。

発生した例外は後述の begin 式の rescue 節で...

絞り込み条件を変える

正規表現 (23018.0)

正規表現 * metachar * expansion * char * anychar * string * str * quantifier * capture * grouping * subexp * selector * anchor * cond * option * encoding * comment * free_format_mode * absenceop * list * specialvar * references

...capture
* grouping
* subexp
* selector
* anchor
* cond
* option
* encoding
* comment
* free_format_mode
* absenceop
* list
* specialvar
* references


正規表現(regular expression)は文字列のパターンを記述するための言語です。
また、この言語で...
...Ruby の文法で特別な意味を持つ文字を埋め込む
ためなどに用いられます。
文字列リテラルの記法とほぼ同様(d:spec/literal#backslash)で、
以下の記法が利用可能です。

\t 水平タブ horizontal tab (0x09)
\v 垂...
...功します。
/"(?:(?>.*)|(.*))"/.match('"Quote"') # => #<MatchData "\"Quote\"" 1:"Quote">
//}

===[a:subexp] 部分式呼び出し(subexpression call)
\g<name> もしくは \g'name'
という記法で、nameと名付けられた部分正規表現にマッチしようとします。
この記法...

Rubyの起動 (23006.0)

Rubyの起動 * cmd_option * shebang

...--mjit-max-cache=num

キャッシュに残すJITされたメソッドの最大個数を指定します。(デフォルト: 10000)

: --mjit-min-calls=num

JITが起動する呼び出し回数を指定します。(テスト用、デフォルト: 10000)

==== YJIT のオプション (実験的)...
...

: --yjit-exec-mem-size=num

MiB単位で実行可能メモリブロックのサイズを指定します。(デフォルト: 256)

: --yjit-call-threshold=num

JITが起動する呼び出し回数を指定します。(テスト用、デフォルト: 10)

: --yjit-max-versions=num

ベー...

セキュリティモデル (23006.0)

セキュリティモデル RubyにはCGI等のプログラミングを安全に行うことを助ける為に、セキュリティ 機構が備わっています。

...危険なパスからの Kernel.#load
* 汚染された文字列を引数にしての Kernel.#load (ラップされていても)
* Kernel.#syscall
* Kernel.#exit!
* Kernel.#trap

==== レベル 3

生成される全てのオブジェクトが汚染されます。

===== 汚染される...
...は $SAFE = 1 以上で実行される。
* Proc はその時点でのセーフレベルを記憶する。
その Proc オブジェクトが call されると、記憶していたセーフレベルで実行される。
* 汚染された文字列を第二引数に指定して Kernel.#trap/...

Method#call(*args) -> object (15120.0)

メソッドオブジェクトに封入されているメソッドを起動します。

...f に渡される引数。

@see UnboundMethod#bind_call
@see spec/safelevel

//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "foo called with arg 2"
//}...

Method#call(*args) { ... } -> object (15120.0)

メソッドオブジェクトに封入されているメソッドを起動します。

...f に渡される引数。

@see UnboundMethod#bind_call
@see spec/safelevel

//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "foo called with arg 2"
//}...

絞り込み条件を変える

Method#call(*args) -> object (15114.0)

メソッドオブジェクトに封入されているメソッドを起動します。

...せん。


@param args self に渡される引数。

@see spec/safelevel

//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "foo called with arg 2"
//}...
<< 1 2 3 > >>