別のキーワード
キーワード
- Array (12)
- Complex (24)
- Float (12)
- Hash (12)
- Integer (12)
- Rational (12)
- String (12)
-
_ id2ref (12) - ` (12)
- abort (24)
- acos (12)
- asin (12)
- atan (12)
- atan2 (12)
- autoload (12)
- caller (36)
- cbrt (12)
- cos (12)
-
count
_ objects (12) -
define
_ finalizer (24) - dump (24)
- empty? (9)
- erf (12)
- erfc (12)
- eval (24)
- exec (48)
- exp (12)
- fail (36)
- fork (24)
- frexp (12)
- gamma (12)
- gets (12)
- groups (12)
- grpowned? (12)
- hypot (12)
- identical? (12)
- lambda (18)
- ldexp (12)
- lgamma (12)
- load (24)
- log (24)
- log10 (12)
- log2 (12)
- loop (24)
- open (24)
- owned? (12)
- p (12)
- print (12)
- printf (24)
- proc (19)
- putc (12)
- puts (12)
- readline (12)
- readlines (12)
- require (12)
-
require
_ relative (12) - restore (12)
-
set
_ trace _ func (12) - setuid? (12)
- sin (12)
- size? (12)
- socket? (12)
- spawn (48)
- sqrt (12)
- sub (24)
- syscall (12)
- system (48)
- tan (12)
- throw (12)
- trap (24)
- wait (12)
- wait2 (12)
- waitpid (12)
- waitpid2 (12)
- warn (12)
- zero? (12)
検索結果
先頭5件
-
Kernel
. # raise -> () (15184.0) -
例外を発生させます。 発生した例外は変数 $! に格納されます。また例外が 発生した時のスタックトレースは変数 $@ に格納され ます。発生した例外は rescue 節で捕捉できます。
...例外が存在しないが自身は捕捉されている時には例外 RuntimeError を発生させます。
//emlist[例][ruby]{
begin
open("nonexist")
rescue
raise #=> `open': No such file or directory - "nonexist" (Errno::ENOENT)
end
//}
引数を渡した場合は、例外メッセー......tion#cause に設定する例外を指定します。
@raise TypeError exception メソッドが例外オブジェクトを返さなかった場合に発生します。
例外の捕捉の例を示します。
//emlist[例1][ruby]{
begin
raise NameError,"!!error!!"
rescue ArgumentError => err
res......emlist[例2][ruby]{
def foo num
print 'in method.'
raise "error!!" if num <= 9
rescue RuntimeError
num += 10
print 'in rescue.'
retry
else
print 'in else.'
ensure
print "in ensure.\n"
end
foo(4) #=> in method.in rescue.in method.in else.in ensure.
//}
//emlist[例3][ruby]{
class MyEx......ブジェクトまたは nil を指定できます。
@raise TypeError exception メソッドが例外オブジェクトを返さなかった場合に発生します。
例外の捕捉の例を示します。
//emlist[例1][ruby]{
begin
raise NameError,"!!error!!"
rescue ArgumentError => err
res... -
Kernel
. # raise(error _ type , message = nil , backtrace = caller(0) , cause: $ !) -> () (15184.0) -
例外を発生させます。 発生した例外は変数 $! に格納されます。また例外が 発生した時のスタックトレースは変数 $@ に格納され ます。発生した例外は rescue 節で捕捉できます。
...例外が存在しないが自身は捕捉されている時には例外 RuntimeError を発生させます。
//emlist[例][ruby]{
begin
open("nonexist")
rescue
raise #=> `open': No such file or directory - "nonexist" (Errno::ENOENT)
end
//}
引数を渡した場合は、例外メッセー......tion#cause に設定する例外を指定します。
@raise TypeError exception メソッドが例外オブジェクトを返さなかった場合に発生します。
例外の捕捉の例を示します。
//emlist[例1][ruby]{
begin
raise NameError,"!!error!!"
rescue ArgumentError => err
res......emlist[例2][ruby]{
def foo num
print 'in method.'
raise "error!!" if num <= 9
rescue RuntimeError
num += 10
print 'in rescue.'
retry
else
print 'in else.'
ensure
print "in ensure.\n"
end
foo(4) #=> in method.in rescue.in method.in else.in ensure.
//}
//emlist[例3][ruby]{
class MyEx......ブジェクトまたは nil を指定できます。
@raise TypeError exception メソッドが例外オブジェクトを返さなかった場合に発生します。
例外の捕捉の例を示します。
//emlist[例1][ruby]{
begin
raise NameError,"!!error!!"
rescue ArgumentError => err
res... -
Kernel
. # raise(message , cause: $ !) -> () (15184.0) -
例外を発生させます。 発生した例外は変数 $! に格納されます。また例外が 発生した時のスタックトレースは変数 $@ に格納され ます。発生した例外は rescue 節で捕捉できます。
...例外が存在しないが自身は捕捉されている時には例外 RuntimeError を発生させます。
//emlist[例][ruby]{
begin
open("nonexist")
rescue
raise #=> `open': No such file or directory - "nonexist" (Errno::ENOENT)
end
//}
引数を渡した場合は、例外メッセー......tion#cause に設定する例外を指定します。
@raise TypeError exception メソッドが例外オブジェクトを返さなかった場合に発生します。
例外の捕捉の例を示します。
//emlist[例1][ruby]{
begin
raise NameError,"!!error!!"
rescue ArgumentError => err
res......emlist[例2][ruby]{
def foo num
print 'in method.'
raise "error!!" if num <= 9
rescue RuntimeError
num += 10
print 'in rescue.'
retry
else
print 'in else.'
ensure
print "in ensure.\n"
end
foo(4) #=> in method.in rescue.in method.in else.in ensure.
//}
//emlist[例3][ruby]{
class MyEx......ブジェクトまたは nil を指定できます。
@raise TypeError exception メソッドが例外オブジェクトを返さなかった場合に発生します。
例外の捕捉の例を示します。
//emlist[例1][ruby]{
begin
raise NameError,"!!error!!"
rescue ArgumentError => err
res... -
Kernel
. # spawn(env , program , *args , options={}) -> Integer (223.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...名文字列、Hash の値に設定する値とします。
nil とすることで環境変数が削除(unsetenv(3))されます。
//emlist[例][ruby]{
# FOO を BAR にして BAZ を削除する
pid = spawn({"FOO"=>"BAR", "BAZ"=>nil}, command)
//}
親プロセスは Process.#waitpid で子プロ......します。
//emlist[][ruby]{
# すべての環境変数をクリア
pid = spawn(command, :unsetenv_others=>true)
# FOO だけ
pid = spawn({"FOO"=>"BAR"}, command, :unsetenv_others=>true)
//}
「:pgroup」でプロセスグループを指定できます。
//emlist[][ruby]{
# true, 0 で新しい......2つの配列、を渡すことができます。
それぞれ Process.#setrlimit の引数が2個、3個の場合に対応します。
//emlist[][ruby]{
# 現プロセスの core の resource limit を取得
cur, max = Process.getrlimit(:CORE)
# 一時的に子プロセスの core dump を止める... -
Kernel
. # spawn(program , *args) -> Integer (223.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...名文字列、Hash の値に設定する値とします。
nil とすることで環境変数が削除(unsetenv(3))されます。
//emlist[例][ruby]{
# FOO を BAR にして BAZ を削除する
pid = spawn({"FOO"=>"BAR", "BAZ"=>nil}, command)
//}
親プロセスは Process.#waitpid で子プロ......します。
//emlist[][ruby]{
# すべての環境変数をクリア
pid = spawn(command, :unsetenv_others=>true)
# FOO だけ
pid = spawn({"FOO"=>"BAR"}, command, :unsetenv_others=>true)
//}
「:pgroup」でプロセスグループを指定できます。
//emlist[][ruby]{
# true, 0 で新しい......2つの配列、を渡すことができます。
それぞれ Process.#setrlimit の引数が2個、3個の場合に対応します。
//emlist[][ruby]{
# 現プロセスの core の resource limit を取得
cur, max = Process.getrlimit(:CORE)
# 一時的に子プロセスの core dump を止める... -
Kernel
. # lambda -> Proc (153.0) -
与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。
...ない lambda は Ruby 2.6 までは警告メッセージ
「warning: tried to create Proc object without a block」
が出力され、Ruby 2.7 では
ArgumentError (tried to create Proc object without a block)
が発生します。
ブロックを指定しない proc は、Ruby 2.7 では
$VERBOSE......が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。
@raise ArgumentError スタック上にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo &block......それ以外では Proc#call)
へジャンプし値を返すには next を使います。break や return ではありません。
//emlist[例][ruby]{
def foo
f = Proc.new{
next 1
2 # この行に到達することはない
}
end
p foo().call #=> 1
//}
===[a:bloc... -
Kernel
. # lambda { . . . } -> Proc (153.0) -
与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。
...ない lambda は Ruby 2.6 までは警告メッセージ
「warning: tried to create Proc object without a block」
が出力され、Ruby 2.7 では
ArgumentError (tried to create Proc object without a block)
が発生します。
ブロックを指定しない proc は、Ruby 2.7 では
$VERBOSE......が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。
@raise ArgumentError スタック上にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo &block......それ以外では Proc#call)
へジャンプし値を返すには next を使います。break や return ではありません。
//emlist[例][ruby]{
def foo
f = Proc.new{
next 1
2 # この行に到達することはない
}
end
p foo().call #=> 1
//}
===[a:bloc... -
Kernel
. # proc -> Proc (153.0) -
与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。
...ない lambda は Ruby 2.6 までは警告メッセージ
「warning: tried to create Proc object without a block」
が出力され、Ruby 2.7 では
ArgumentError (tried to create Proc object without a block)
が発生します。
ブロックを指定しない proc は、Ruby 2.7 では
$VERBOSE......が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。
@raise ArgumentError スタック上にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo &block......それ以外では Proc#call)
へジャンプし値を返すには next を使います。break や return ではありません。
//emlist[例][ruby]{
def foo
f = Proc.new{
next 1
2 # この行に到達することはない
}
end
p foo().call #=> 1
//}
===[a:bloc... -
Kernel
. # proc { . . . } -> Proc (153.0) -
与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。
...ない lambda は Ruby 2.6 までは警告メッセージ
「warning: tried to create Proc object without a block」
が出力され、Ruby 2.7 では
ArgumentError (tried to create Proc object without a block)
が発生します。
ブロックを指定しない proc は、Ruby 2.7 では
$VERBOSE......が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。
@raise ArgumentError スタック上にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo &block......それ以外では Proc#call)
へジャンプし値を返すには next を使います。break や return ではありません。
//emlist[例][ruby]{
def foo
f = Proc.new{
next 1
2 # この行に到達することはない
}
end
p foo().call #=> 1
//}
===[a:bloc... -
Kernel
. # lambda { . . . } -> Proc (105.0) -
与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。
...iteral block is deprecated; use the proc without lambda instead」
を出力します。
@raise ArgumentError ブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo &block
lambda(&block)
end
it = foo{p 12}
it.call #=> 12
//}
@see Proc,Proc.n......それ以外では Proc#call)
へジャンプし値を返すには next を使います。break や return ではありません。
//emlist[例][ruby]{
def foo
f = Proc.new{
next 1
2 # この行に到達することはない
}
end
p foo().call #=> 1
//}
===[a:bloc......ブジェクトが呼び出しブロックとして振舞う際の制限です。
//emlist[問題なし][ruby]{
(1..5).each { break }
//}
//emlist[LocalJumpError が発生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}
===[a:lambda_proc] lambda と proc と Proc.new とイテレ......iteral block is deprecated; use the proc without lambda instead」
を出力します。
@raise ArgumentError ブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo &block
proc(&block)
end
it = foo{p 12}
it.call #=> 12
//}
@see Proc,Proc.new... -
Kernel
. # proc { . . . } -> Proc (105.0) -
与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。
...iteral block is deprecated; use the proc without lambda instead」
を出力します。
@raise ArgumentError ブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo &block
lambda(&block)
end
it = foo{p 12}
it.call #=> 12
//}
@see Proc,Proc.n......それ以外では Proc#call)
へジャンプし値を返すには next を使います。break や return ではありません。
//emlist[例][ruby]{
def foo
f = Proc.new{
next 1
2 # この行に到達することはない
}
end
p foo().call #=> 1
//}
===[a:bloc......ブジェクトが呼び出しブロックとして振舞う際の制限です。
//emlist[問題なし][ruby]{
(1..5).each { break }
//}
//emlist[LocalJumpError が発生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}
===[a:lambda_proc] lambda と proc と Proc.new とイテレ......iteral block is deprecated; use the proc without lambda instead」
を出力します。
@raise ArgumentError ブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo &block
proc(&block)
end
it = foo{p 12}
it.call #=> 12
//}
@see Proc,Proc.new... -
Kernel
. # system(command , options={}) -> bool | nil (94.0) -
引数を外部コマンドとして実行して、成功した時に真を返します。
...ドを実行することができなかった場合、多くのシェルはステータス
127 を返します。シェルを介さない場合は Ruby の子プロセスがステータス
127 で終了します。
コマンドが実行できなかったのか、コマンドが失敗したのかは......する環境変数を表す Hash
@param options オプションパラメータ Hash
@raise Errno::EXXX exception: true が指定されていて、コマンドの実行が失敗したときに発生します。
@raise RuntimeError exception: true が指定されていて、コマンドの終了ステ......ル経由でコマンドを実行][ruby]{
system("echo *") # => true
# fileA fileB fileC ...
//}
//emlist[exceptionオプションを指定][ruby]{
system("sad", exception: true) # => Errno::ENOENT (No such file or directory - sad)
system('ruby -e "exit(false)"', exception: true)...