るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

クラス

モジュール

キーワード

検索結果

<< < 1 2 >>

Kernel.#pp(*obj) -> object (21014.0)

指定されたオブジェクト obj を標準出力に見やすい形式(プリティプリント)で出力します。 obj それぞれを引数として PP.pp を呼ぶことと同等です。

...して PP.pp を呼ぶことと同等です。

初回呼び出し時に自動的に pp を require します。

@param obj 表示したいオブジェクトを指定します。

//emlist[例][ruby]{
require
'pp'

b = [1, 2, 3] * 4
a = [b, b]
a << a
pp a

#=> [[1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],...

LoadError#path -> String | nil (56.0)

Kernel.#require や Kernel.#load に失敗したパスを返します。

...
Kernel.#require
Kernel.#load に失敗したパスを返します。

begin
require
'this/file/does/not/exist'
rescue LoadError => e
e.path # => 'this/file/does/not/exist'
end

パスが定まらない場合は nil を返します。...

Module#autoload(const_name, feature) -> nil (52.0)

定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。

...定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。

const_name が autoload 設定されていて、まだ定義されてない(ロードされていない)ときは、
autoload する対象を置き換えます。
const_name が(autoload...
...含めることはできません。
つまり、self の直下に定義された定数しか指定できません。

@param feature Kernel.#require と同様な方法で autoload する対象を指定する。

//emlist[例][ruby]{
# ------- /tmp/foo.rb ---------
class Foo
class Bar
end...
...nstant Bar referenced by Foo::Bar
# Bar
# nil
//}

これは以下のようにネストせずに定義したのと同じことです。

//emlist[例][ruby]{
class Foo
end
class Bar
end
p Foo::Bar
#=> -:5: warning: toplevel constant Bar referenced by Foo::Bar
# Bar
//}

@see Kernel.#autoload...
...ない場
合、NameError が発生します。

//emlist[例][ruby]{
# ------- /tmp/bar.rb ---------
class Bar
end
# ----- end of /tmp/bar.rb ----

class Foo
autoload :Bar, '/tmp/bar.rb'
end
p Foo::Bar
#=> -:4:in `<main>': uninitialized constant Foo::Bar (NameError)
//}

@see Kernel.#autoload...

LoadError (50.0)

Kernel.#require や Kernel.#load が失敗したときに発生します。

...Kernel.#require Kernel.#load が失敗したときに発生します。...

Random#rand -> Float (32.0)

一様な擬似乱数を発生させます。

...に負の数値を与えた時や (1..0) のような値が存在しない範囲を渡した時などに発生します。

//emlist[例][ruby]{
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand(1234)
rand # => 0....
...g.rand(Time.new(2012, 1, 1) ... Time.new(2013,1,1)) # => 2012-02-25 03:11:42 +0900
require
'date'
prng.rand(Date.new(2012, 1, 1) ... Date.new(2013,1,1)) # => #<Date: 2012-01-31 ((2455958j,0s,0n),+0s,2299161j)>
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand...
...見える

# 上と同じ種で再初期化
prng = Random.new(1234)
srand(1234)
# Kernel.#rand は Array#sample などの影響を受けて値がずれることがある
[0, 1].sample
prng.rand #=> 0.1915194503788923
rand #=> 0.6221087710398319
//}


@see Kernel.#rand...

絞り込み条件を変える

Random#rand(max) -> Integer | Float (32.0)

一様な擬似乱数を発生させます。

...に負の数値を与えた時や (1..0) のような値が存在しない範囲を渡した時などに発生します。

//emlist[例][ruby]{
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand(1234)
rand # => 0....
...g.rand(Time.new(2012, 1, 1) ... Time.new(2013,1,1)) # => 2012-02-25 03:11:42 +0900
require
'date'
prng.rand(Date.new(2012, 1, 1) ... Date.new(2013,1,1)) # => #<Date: 2012-01-31 ((2455958j,0s,0n),+0s,2299161j)>
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand...
...見える

# 上と同じ種で再初期化
prng = Random.new(1234)
srand(1234)
# Kernel.#rand は Array#sample などの影響を受けて値がずれることがある
[0, 1].sample
prng.rand #=> 0.1915194503788923
rand #=> 0.6221087710398319
//}


@see Kernel.#rand...

Random#rand(range) -> Integer | Float (32.0)

一様な擬似乱数を発生させます。

...に負の数値を与えた時や (1..0) のような値が存在しない範囲を渡した時などに発生します。

//emlist[例][ruby]{
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand(1234)
rand # => 0....
...g.rand(Time.new(2012, 1, 1) ... Time.new(2013,1,1)) # => 2012-02-25 03:11:42 +0900
require
'date'
prng.rand(Date.new(2012, 1, 1) ... Date.new(2013,1,1)) # => #<Date: 2012-01-31 ((2455958j,0s,0n),+0s,2299161j)>
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand...
...見える

# 上と同じ種で再初期化
prng = Random.new(1234)
srand(1234)
# Kernel.#rand は Array#sample などの影響を受けて値がずれることがある
[0, 1].sample
prng.rand #=> 0.1915194503788923
rand #=> 0.6221087710398319
//}


@see Kernel.#rand...

Object::DATA -> File (26.0)

スクリプトの __END__ プログラムの終り以降をアクセスする File オブジェクト。

...標準入力から読みこまれなかった場合や、
__END__ で終っていない場合には定義されません。
* Kernel.#require Kernel.#load で
読み込まれたファイルの中であってもそのファイル (__FILE__, d:spec/variables#pseudo)
ではな...
...ary.rb と app.rb の内容が以下であったとします。

library.rb:
print DATA.gets

__END__
data from library

app.rb:
require
'library.rb'

__END__
data from app

このときシェルから次を実行すると
$ ruby app.rb
結果は以下のように出...

Object::SCRIPT_LINES__ -> Hash (20.0)

ソースファイル別にまとめられたソースコードの各行。

...この定数はデバッガ (debug) などで利用されています。

また、 Kernel.#eval によるコンパイルは対象にはなりません。


例:
require
'pp'
SCRIPT_LINES__ = {}
require
'English'
pp SCRIPT_LINES__

# => {"/usr/local/lib/ruby/1.6/English.rb"=>...
<< < 1 2 >>