別のキーワード
ライブラリ
- ビルトイン (1739)
- base64 (22)
- bigdecimal (132)
-
bigdecimal
/ math (66) -
bigdecimal
/ util (33) - date (113)
-
digest
/ sha2 (11) - etc (44)
- fileutils (17)
- getoptlong (22)
-
io
/ console (11) - ipaddr (11)
- json (11)
- matrix (78)
-
net
/ http (22) - observer (11)
- open-uri (22)
- optparse (154)
- pathname (22)
-
rdoc
/ markup / to _ html _ crossref (11) -
rubygems
/ installer (11) -
rubygems
/ requirement (11) -
rubygems
/ version (22) - set (231)
- shellwords (44)
- socket (11)
- stringio (11)
- strscan (22)
- syslog (99)
-
test
/ unit (1) - time (77)
- tmpdir (22)
- uri (55)
-
webrick
/ utils (11) - zlib (11)
クラス
-
ARGF
. class (22) - Array (165)
- BasicSocket (11)
- BigDecimal (88)
- Data (10)
- Date (36)
- DateTime (77)
-
Digest
:: SHA2 (11) - Dir (22)
- Encoding (11)
-
Enumerator
:: Lazy (173) - File (14)
- Float (22)
- FrozenError (5)
-
Gem
:: Installer (11) -
Gem
:: Requirement (11) -
Gem
:: Version (22) - GetoptLong (22)
- Hash (44)
- IO (55)
- IPAddr (11)
- Integer (92)
- KeyError (14)
- Matrix (44)
- Module (11)
-
Net
:: HTTP (22) - Numeric (84)
- Object (88)
- OptionParser (154)
- Pathname (22)
- Proc (18)
-
RDoc
:: Markup :: ToHtmlCrossref (11) - Random (77)
- Range (87)
- Rational (11)
- Set (231)
- String (33)
- StringIO (11)
- StringScanner (22)
- Struct (44)
- Thread (20)
- Time (201)
- TracePoint (7)
-
URI
:: FTP (33) - Vector (34)
-
Zlib
:: GzipReader (11)
モジュール
- Base64 (22)
- BigMath (88)
- Comparable (65)
- Enumerable (44)
- Etc (44)
- FileUtils (17)
- JSON (11)
- Kernel (355)
- Marshal (22)
- Observable (11)
- OpenURI (22)
- Process (22)
-
Process
:: GID (22) -
Process
:: UID (22) - Shellwords (33)
- Signal (22)
- Syslog (99)
-
Test
:: Unit (1) - URI (22)
-
WEBrick
:: Utils (11)
オブジェクト
- main (11)
キーワード
- & (11)
- * (33)
- + (11)
- - (11)
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - < (11)
- <= (11)
- > (11)
- >= (11)
- BigDecimal (22)
- Complex (22)
- E (11)
- Float (11)
- Integer (11)
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 2
. 1 . 0 (11) -
NEWS for Ruby 2
. 5 . 0 (7) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) - PI (11)
- Rational (11)
- [] (52)
- []= (12)
- ^ (11)
- add (11)
- alert (11)
- atan (11)
- begin (11)
- between? (11)
- build (22)
-
change
_ privilege (22) -
chunk
_ while (8) - civil (17)
- clamp (10)
- clone (11)
-
cofactor
_ expansion (11) - collect (11)
-
collect
_ concat (11) - commercial (17)
- cos (11)
-
cp
_ lr (6) - create (11)
-
create
_ listeners (11) - crit (11)
- cross (11)
-
cross
_ product (11) - debug (11)
-
decode
_ www _ form (11) -
decode
_ www _ form _ component (11) - detect (22)
- difference (11)
- digits (22)
- dirname (3)
- disjoint? (11)
- div (11)
- drop (11)
- dump (33)
- dup (11)
- emerg (11)
- empty (11)
- end (11)
-
enum
_ for (44) - err (11)
- exec (44)
- exp (11)
-
extract
_ files (11) - fail (33)
- fileno (11)
- filter (6)
-
filter
_ map (5) - find (33)
-
find
_ all (11) - first (44)
-
first
_ minor (11) -
flat
_ map (11) - flatten (22)
- flatten! (22)
-
from
_ name (22) - gcd (11)
- gcdlcm (11)
- getgrgid (11)
- getgrnam (11)
- getpwnam (11)
- getpwuid (11)
- gm (22)
- groups= (11)
-
handle
_ interrupt (11) - httpdate (11)
- include (22)
- info (11)
- inspect (11)
- intersect? (11)
- intersection (11)
- iso8601 (11)
- jd (11)
- join (22)
- key (7)
- kill (11)
- lambda (17)
-
laplace
_ expansion (11) - last (44)
- lcm (11)
- limit (11)
- local (22)
- log (22)
- map (11)
-
marshal
_ load (11) - merge (11)
- mktime (22)
- mktmpdir (22)
- mode (22)
- mult (11)
- name= (9)
-
net
/ http (11) - new (225)
- new2 (11)
- notice (11)
-
notify
_ observers (11) - now (11)
- on (132)
-
open
_ uri (22) - ord (11)
- ordering= (11)
- ordinal (17)
- parse (50)
- peek (11)
- peep (11)
- printf (22)
- proc (18)
-
proper
_ subset? (11) -
proper
_ superset? (11) -
public
_ send (22) - rand (66)
- raw (11)
-
rb
_ time _ timespec _ new (9) - read (44)
- readpartial (11)
- receiver (12)
- reject (33)
-
relative
_ path _ from (11) - replace (11)
- request (22)
- rfc2822 (11)
- rfc822 (11)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 4 feature (11) - sample (44)
- seek (11)
- select (11)
-
setup
_ argv (1) - shellsplit (22)
- shellwords (11)
- shift (22)
- shutdown (11)
- sin (11)
- spawn (44)
- split (11)
- sqrt (22)
- step (94)
-
strict
_ decode64 (11) - strptime (17)
- sub (33)
- subset? (11)
- subtract (11)
- superset? (11)
- system (44)
- take (11)
- throw (1)
-
to
_ d (33) -
to
_ enum (44) -
to
_ i (11) -
to
_ s (11) - trap (22)
- union (11)
- uptodate? (11)
-
urlsafe
_ decode64 (11) - utc (22)
- warning (11)
- with (2)
- xmlschema (11)
- | (11)
検索結果
先頭5件
-
Kernel
. # raise -> () (15139.0) -
例外を発生させます。 発生した例外は変数 $! に格納されます。また例外が 発生した時のスタックトレースは変数 $@ に格納され ます。発生した例外は rescue 節で捕捉できます。
...ないが自身は捕捉されている時には例外 RuntimeError を発生させます。
//emlist[例][ruby]{
begin
open("nonexist")
rescue
raise #=> `open': No such file or directory - "nonexist" (Errno::ENOENT)
end
//}
引数を渡した場合は、例外メッセージ message を持......る例外を指定します。
@raise TypeError exception メソッドが例外オブジェクトを返さなかった場合に発生します。
例外の捕捉の例を示します。
//emlist[例1][ruby]{
begin
raise NameError,"!!error!!"
rescue ArgumentError => err
rescue NameError => err
re......scue TypeError => err
ensure
p err #=> #<NameError: !!error!!>
end
//}
//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.......nil を指定できます。
@raise TypeError exception メソッドが例外オブジェクトを返さなかった場合に発生します。
例外の捕捉の例を示します。
//emlist[例1][ruby]{
begin
raise NameError,"!!error!!"
rescue ArgumentError => err
rescue NameError => err
res......cue TypeError => err
ensure
p err #=> #<NameError: !!error!!>
end
//}
//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.i... -
Kernel
. # raise(error _ type , message = nil , backtrace = caller(0) , cause: $ !) -> () (15139.0) -
例外を発生させます。 発生した例外は変数 $! に格納されます。また例外が 発生した時のスタックトレースは変数 $@ に格納され ます。発生した例外は rescue 節で捕捉できます。
...ないが自身は捕捉されている時には例外 RuntimeError を発生させます。
//emlist[例][ruby]{
begin
open("nonexist")
rescue
raise #=> `open': No such file or directory - "nonexist" (Errno::ENOENT)
end
//}
引数を渡した場合は、例外メッセージ message を持......る例外を指定します。
@raise TypeError exception メソッドが例外オブジェクトを返さなかった場合に発生します。
例外の捕捉の例を示します。
//emlist[例1][ruby]{
begin
raise NameError,"!!error!!"
rescue ArgumentError => err
rescue NameError => err
re......scue TypeError => err
ensure
p err #=> #<NameError: !!error!!>
end
//}
//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.......nil を指定できます。
@raise TypeError exception メソッドが例外オブジェクトを返さなかった場合に発生します。
例外の捕捉の例を示します。
//emlist[例1][ruby]{
begin
raise NameError,"!!error!!"
rescue ArgumentError => err
rescue NameError => err
res......cue TypeError => err
ensure
p err #=> #<NameError: !!error!!>
end
//}
//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.i... -
Kernel
. # raise(message , cause: $ !) -> () (15139.0) -
例外を発生させます。 発生した例外は変数 $! に格納されます。また例外が 発生した時のスタックトレースは変数 $@ に格納され ます。発生した例外は rescue 節で捕捉できます。
...ないが自身は捕捉されている時には例外 RuntimeError を発生させます。
//emlist[例][ruby]{
begin
open("nonexist")
rescue
raise #=> `open': No such file or directory - "nonexist" (Errno::ENOENT)
end
//}
引数を渡した場合は、例外メッセージ message を持......る例外を指定します。
@raise TypeError exception メソッドが例外オブジェクトを返さなかった場合に発生します。
例外の捕捉の例を示します。
//emlist[例1][ruby]{
begin
raise NameError,"!!error!!"
rescue ArgumentError => err
rescue NameError => err
re......scue TypeError => err
ensure
p err #=> #<NameError: !!error!!>
end
//}
//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.......nil を指定できます。
@raise TypeError exception メソッドが例外オブジェクトを返さなかった場合に発生します。
例外の捕捉の例を示します。
//emlist[例1][ruby]{
begin
raise NameError,"!!error!!"
rescue ArgumentError => err
rescue NameError => err
res......cue TypeError => err
ensure
p err #=> #<NameError: !!error!!>
end
//}
//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.i... -
ruby 1
. 6 feature (84.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...$; が有効にな
るのは引数省略時だけでした。
$; = ":"
p "a:b:c".split(nil)
=> -:2:in `split': bad separator (ArgumentError)
from -:2
ruby 1.6.7 (2002-03-01) [i586-linux]
=> ruby 1.6.7 (2002-07-30) [i586-linux]
["a", "b", "c"]
: 2002-06......0 を指定したと見なされエラーになって
いました。
1.step(2, 0.1) {|f| p f }
=> -:1:in `step': step cannot be 0 (ArgumentError)
from -:1
ruby 1.6.7 (2002-03-01) [i586-linux]
=> ruby 1.6.7 (2002-04-10) [i586-linux]
1
1.1
:......(rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) {
+ if (rb_safe_level() >= 4 && (klass == rb_cObject || !OBJ_TAINTED(klass))) {
rb_raise(rb_eSecurityError, "Insecure: can't define method");
}
if (OBJ_FROZEN(klass)) rb_error_frozen("class/module");
また今度... -
Kernel
. # Float(arg) -> Float (54.0) -
引数を浮動小数点数(Float)に変換した結果を返します。
...な変換を行います。
@param arg 変換対象のオブジェクトです。
@raise ArgumentError 整数や浮動小数点数と見なせない文字列を引数に指定した場合に発生します。
@raise TypeError nil またはメソッド to_f を持たないオブジェクトを引数......loat(): "nan" (ArgumentError)
p Float("INF") # invalid value for Float(): "INF" (ArgumentError)
p Float("-Inf") # invalid value for Float(): "-Inf" (ArgumentError)
p Float(("10" * 1000)) #=> Infinity
p Float("0xa.a") # invalid value for Float(): "0xa.a" (ArgumentError)
p Float(" \n......10\s \t") #=> 10.0 # 先頭と末尾の空白類は無視される
p Float("1\n0") # invalid value for Float(): "1\n0" (ArgumentError)
p Float("") # invalid value for Float(): "" (ArgumentError)
//}
@see String#to_f,Float... -
Kernel
. # Float(arg , exception: true) -> Float | nil (54.0) -
引数を浮動小数点数(Float)に変換した結果を返します。
...合、
例外を発生する代わりに nil を返します。
@raise ArgumentError 整数や浮動小数点数と見なせない文字列を引数に指定した場合に発生します。
@raise TypeError nil またはメソッド to_f を持たないオブジェクトを引数......loat(): "nan" (ArgumentError)
p Float("INF") # invalid value for Float(): "INF" (ArgumentError)
p Float("-Inf") # invalid value for Float(): "-Inf" (ArgumentError)
p Float(("10" * 1000)) #=> Infinity
p Float("0xa.a") # invalid value for Float(): "0xa.a" (ArgumentError)
p Float(" \n......10\s \t") #=> 10.0 # 先頭と末尾の空白類は無視される
p Float("1\n0") # invalid value for Float(): "1\n0" (ArgumentError)
p Float("") # invalid value for Float(): "" (ArgumentError)
//}
@see String#to_f,Float... -
NEWS for Ruby 2
. 7 . 0 (54.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ド引数付きで呼び出すとArgumentErrorになります。 14183
//emlist[][ruby]{
def foo(h, **nil); end; foo(key: 1) # ArgumentError
def foo(h, **nil); end; foo(**{key: 1}) # ArgumentError
def foo(h, **nil); end; foo("str" => 1) # ArgumentError
def foo(h, **nil); end; foo({key: 1}......するようになりました。
//emlist[][ruby]{
def bar
lambda
end
bar { puts "Hello" } #=> tried to create Proc object without a block (ArgumentError)
//}
==== その他の変更
* 始端なしRangeが実験的に導入されました。
caseやComparable#clampや定数やDSLなど......ュメントの識別子の引用符は同じ行で閉じる必要があります。
//emlist{
<<"EOS
" # This had been warned since 2.4; Now it raises a SyntaxError
EOS
//}
* フリップフロップが非推奨になったのが元に戻されました。 5400
* 以下のような場所に... -
Kernel
. # Rational(x , y = 1) -> Rational (48.0) -
引数を有理数(Rational)に変換した結果を返します。
...対象のオブジェクトです。省略した場合は x だけを用いて
Rational オブジェクトを作成します。
@raise ArgumentError 変換できないオブジェクトを指定した場合に発生します。
引数 x、y の両方を指定した場合、x/y した Rat......=> (2/5)
Rational('1/3.1') # => ArgumentError
Rational('3.0', '3.0') # => (1/1)
Rational('3/3', '3/3') # => (1/1)
Rational('1_234_567') # => (1234567/1)
Rational(" \n10\t ") # => (10/1) # 空白類は無視される
Rational("0x10") # => ArgumentError
//}
引数に変換できない......オブジェクトを指定した場合には ArgumentError が
発生します。
//emlist[例][ruby]{
Rational(Object.new) # => ArgumentError
Rational("") # => ArgumentError
Rational(nil) # => ArgumentError
//}
また、Rational('0.3') と Rational(0.3) は異なるオブジ... -
Kernel
. # Rational(x , y = 1 , exception: true) -> Rational | nil (48.0) -
引数を有理数(Rational)に変換した結果を返します。
...ion false を指定すると、変換できなかった場合、
例外を発生する代わりに nil を返します。
@raise ArgumentError 変換できないオブジェクトを指定した場合に発生します。
引数 x、y の両方を指定した場合、x/y した Ra......=> (2/5)
Rational('1/3.1') # => ArgumentError
Rational('3.0', '3.0') # => (1/1)
Rational('3/3', '3/3') # => (1/1)
Rational('1_234_567') # => (1234567/1)
Rational(" \n10\t ") # => (10/1) # 空白類は無視される
Rational("0x10") # => ArgumentError
//}
引数に変換できない......オブジェクトを指定した場合には ArgumentError が
発生します。
//emlist[例][ruby]{
Rational(Object.new) # => ArgumentError
Rational("") # => ArgumentError
Rational(nil) # => ArgumentError
//}
また、Rational('0.3') と Rational(0.3) は異なるオブジ... -
Kernel
. # Integer(arg , base = 0) -> Integer (42.0) -
引数を整数(Fixnum,Bignum)に変換した結果を返します。
...)、0 (8 進数)、0o (8 進数)、0d (10 進数)、0x (16 進
数) です。
@raise ArgumentError 整数と見なせない文字列を引数に指定した場合に発生します。
@raise TypeError メソッド to_int, to_i を持たないオブジェクトを引数に指定した......か、to_int, to_i
が整数(Integerのサブクラス)を返さなかった場合に発生します。
@raise TypeError 引数に nil を指定した場合に発生します。
//emlist[例][ruby]{
p Integer(4) #=> 4
p Integer(4_000) #=> 4000
p Integer(9.88) #=> 9
p Integer(......teger("1\n0") # `Integer': invalid value for Integer: "1\n0" (ArgumentError)
p Integer("hoge") # `Integer': invalid value for Integer: "hoge" (ArgumentError)
p Integer("") # `Integer': invalid value for Integer: "" (ArgumentError)
//}
@see String#hex,String#oct,String#to_i,Integer... -
Kernel
. # Integer(arg , base = 0 , exception: true) -> Integer | nil (42.0) -
引数を整数(Fixnum,Bignum)に変換した結果を返します。
...かった場合、
例外を発生する代わりに nil を返します。
@raise ArgumentError 整数と見なせない文字列を引数に指定した場合に発生します。
@raise TypeError メソッド to_int, to_i を持たないオブジェクトを引数に指定した......か、to_int, to_i
が整数(Integerのサブクラス)を返さなかった場合に発生します。
@raise TypeError 引数に nil を指定した場合に発生します。
//emlist[例][ruby]{
p Integer(4) #=> 4
p Integer(4_000) #=> 4000
p Integer(9.88) #=> 9
p Integer(......teger("1\n0") # `Integer': invalid value for Integer: "1\n0" (ArgumentError)
p Integer("hoge") # `Integer': invalid value for Integer: "hoge" (ArgumentError)
p Integer("") # `Integer': invalid value for Integer: "" (ArgumentError)
//}
@see String#hex,String#oct,String#to_i,Integer... -
Kernel
. # fail -> () (39.0) -
例外を発生させます。 発生した例外は変数 $! に格納されます。また例外が 発生した時のスタックトレースは変数 $@ に格納され ます。発生した例外は rescue 節で捕捉できます。
...ないが自身は捕捉されている時には例外 RuntimeError を発生させます。
//emlist[例][ruby]{
begin
open("nonexist")
rescue
raise #=> `open': No such file or directory - "nonexist" (Errno::ENOENT)
end
//}
引数を渡した場合は、例外メッセージ message を持......る例外を指定します。
@raise TypeError exception メソッドが例外オブジェクトを返さなかった場合に発生します。
例外の捕捉の例を示します。
//emlist[例1][ruby]{
begin
raise NameError,"!!error!!"
rescue ArgumentError => err
rescue NameError => err
re......scue TypeError => err
ensure
p err #=> #<NameError: !!error!!>
end
//}
//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.......nil を指定できます。
@raise TypeError exception メソッドが例外オブジェクトを返さなかった場合に発生します。
例外の捕捉の例を示します。
//emlist[例1][ruby]{
begin
raise NameError,"!!error!!"
rescue ArgumentError => err
rescue NameError => err
res......cue TypeError => err
ensure
p err #=> #<NameError: !!error!!>
end
//}
//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.i... -
Kernel
. # fail(error _ type , message = nil , backtrace = caller(0) , cause: $ !) -> () (39.0) -
例外を発生させます。 発生した例外は変数 $! に格納されます。また例外が 発生した時のスタックトレースは変数 $@ に格納され ます。発生した例外は rescue 節で捕捉できます。
...ないが自身は捕捉されている時には例外 RuntimeError を発生させます。
//emlist[例][ruby]{
begin
open("nonexist")
rescue
raise #=> `open': No such file or directory - "nonexist" (Errno::ENOENT)
end
//}
引数を渡した場合は、例外メッセージ message を持......る例外を指定します。
@raise TypeError exception メソッドが例外オブジェクトを返さなかった場合に発生します。
例外の捕捉の例を示します。
//emlist[例1][ruby]{
begin
raise NameError,"!!error!!"
rescue ArgumentError => err
rescue NameError => err
re......scue TypeError => err
ensure
p err #=> #<NameError: !!error!!>
end
//}
//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.......nil を指定できます。
@raise TypeError exception メソッドが例外オブジェクトを返さなかった場合に発生します。
例外の捕捉の例を示します。
//emlist[例1][ruby]{
begin
raise NameError,"!!error!!"
rescue ArgumentError => err
rescue NameError => err
res......cue TypeError => err
ensure
p err #=> #<NameError: !!error!!>
end
//}
//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.i...