るりまサーチ

最速Rubyリファレンスマニュアル検索!
958件ヒット [1-100件を表示] (0.089秒)
トップページ > クエリ:nil[x] > クエリ:end[x] > クエリ:print[x]

別のキーワード

  1. _builtin nil?
  2. nilclass nil?
  3. object nil?
  4. _builtin nil
  5. object nil

ライブラリ

クラス

モジュール

検索結果

<< 1 2 3 ... > >>

Kernel.#print(*arg) -> nil (18280.0)

引数を順に標準出力 $stdout に出力します。引数が与えられない時には変数 $_ の値を出力します。

...力します。

変数 $, (出力フィールドセパレータ)に nil
ない値がセットされている時には、各引数の間にその文字列を出力します。
変数 $\ (出力レコードセパレータ)に nil でな
い値がセットされている時には、最後にそれ...
...た場合に発生します。

//emlist[例][ruby]{
print
"Hello, world!"
print
"Regexp is",/ant/
print
nil
print
"\n"
#=> Hello, world!Regexp is(?-mix:ant)

$_ = "input"
$, = "<and>"
$\ = "<end>\n"
print

print
"AA","BB"
#=> input<end>
#=> AA<and>BB<end>
//}

@see Kernel.#puts,Kernel.#p,IO#print...

1.6.8から1.8.0への変更点(まとめ) (1242.0)

1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))

...りました。
* nil: 警告を出力しない (-W0 新しい警告レベル)
* false: 重要な警告のみ出力 (-W1 デフォルト)
* true: すべての警告を出力する (-W2 or -W or -v or -w or --verbose)

追加された -W オプションは $VERBOSE = nil の指定(-W0)を...
...よくわかりません(^^;

class << Object
p [self.id, self]
class << self
p [self.id, self]
end

end

=> ruby 1.6.7 (2002-03-01) [i586-linux]
[537771634, Class]
[537742484, Class]
=> ruby 1.7.3 (2002-09...
...
((<ruby-dev:14172>))

== 拡張されたクラス/メソッド(互換性のある変更)

=== 組み込み関数

: ((<組み込み関数/sprintf>)) [new]

"%p" が追加されました。inspect の結果が利用されます。((<RCR#69>))

: ((<組み込み関数/trap>)) [compat]

...

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

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

...fined

===[a:class] クラス定義

//emlist[例][ruby]{
class Foo < Super
def test
# ...
end

# ...
end

//}

文法:

class 識別子 [`<' superclass ]
式..
end


文法:

class 識別子 [`<' superclass ]
式..
[rescue [erro...
...返さない場合は nil を返します。

===[a:singleton_class] 特異クラス定義

//emlist[例][ruby]{
obj = Object.new # obj = nil でも可
class << obj
def test
# ...
end

# ...
end

//}

文法:

class `<<' expr
式..
end


文法:

clas...
...与えられなかった場合のブロック引数の値はnilです。

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

foo(3) { print "Ruby! " } #=> Ruby! Ruby! Ruby!
//}

メソッド定義にお...

制御構造 (598.0)

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

...* until
* for
* break
* next
* redo
* retry
例外処理:
* raise
* begin
その他:
* return
* BEGIN
* END

Rubyでは(Cなどとは異なり)制御構造は式であって、何らかの値を返すものが
あります(返さないものもありま...
...then
print
"adult fee\n"
else
print
"child fee\n"
end

gender = if foo.gender == "male" then "male" else "female" end
//}

文法:

if 式 [then]
式 ...
[elsif 式 [then]
式 ... ]
...
[else
式 ... ]
end


...
...節)の最後に評価し
た式の結果を返します。else 節がなくいずれの条件も成り立たなけれ
nil を返します。

Ruby では false または nil だけが偽で、それ以外は 0 や空文
字列も含め全て真です。

Ruby では if を繋げるのは elsif...

ruby 1.6 feature (576.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

... nil
を返すようになりました。(String#[]やString#slice と同じ結果を返すと
いうことです)

p "foo".slice!("bar") # <- 以前からこちらは nil を返していた
p "foo".slice!(5,10)

=> ruby 1.6.7 (2002-03-01) [i586-linux]
nil
...
...) [i586-linux]

: 2002-06-03 sprintf()

"%d" で引数を整数にするときに、((<組み込み関数/Integer>)) と同じ規則を
使用するようになりました。

p sprintf("%d", nil)

=> -:1:in `sprintf': no implicit conversion from nil (TypeError)...
...ーになっていました。
((<ruby-dev:17155>))

open("|-","r+") {|f|
if f
f.dup.close_write
else
sleep 1
end

}

=> ruby 1.6.7 (2002-03-01) [i586-linux]
-:3:in `close_write': closing non-duplex IO for writing (IOError)
from -:3...

絞り込み条件を変える

rss (468.0)

RSS を扱うためのライブラリです。

...RSS を扱うためのライブラリです。

=== 参考

* RSS 0.91 http://backend.userland.com/rss091
* RSS 1.0 http://purl.org/rss/1.0/spec
* RSS 2.0 http://www.rssboard.org/rss-specification
* Atom 1.0 https://www.ietf.org/rfc/rfc4287.txt

=== 注意

RSS ParserはRSS 0.9x/1.0/2.0, A...
...は,
例外 RSS::NotWellFormedError が発生します。well formed な
XML だが,RSS 0.9x/1.0/2.0, Atom のいずれでもない場合は,nil
返ります.

例えば、RSS 1.0 をバリデーション付きでパースするには以下のよ
うにします。ここで、変数 rss_...
...name|
feed = nil
begin
feed = RSS::Parser.parse(File.read(fname), false)
rescue RSS::Error
end


if feed.nil?
puts "#{fname}はRSS 0.9x/1.0/2.0, Atom 1.0のいずれでもありません。"
else
print
_items(feed)
end

end


あとはprint_itemsという...

IO.select(reads, writes = [], excepts = [], timeout = nil) -> [[IO]] | nil (244.0)

select(2) を実行します。

...トの中から準備ができたものを
それぞれ配列にして、配列の配列として返します。
タイムアウトした時には nil を返します。

@param reads 入力待ちする IO オブジェクトの配列を渡します。

@param writes 出力待ちする IO オブジ...
...IO.pipe
mesg = "ping "
100.times{
rs, ws, = IO.select([rp], [wp])
if r = rs[0]
ret = r.read(5)
print
ret
case ret
when /ping/
mesg = "pong\n"
when /pong/
mesg = "ping "
end

end

if w = ws[0]
w.write(mesg)
end

}

@see Kernel.#select...

irb (234.0)

irb は Interactive Ruby の略です。 irb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。

...されます。

irb(main):001:0> 1+2
3
irb(main):002:0> class Foo
irb(main):003:1> def foo
irb(main):004:2> print 1
irb(main):005:2> end
irb(main):006:1> end
:foo
irb(main):007:0>

また irb コマンドは readline ライブラリにも対応しています。
readline...
...nf[:DEBUG_LEVEL] = 1
IRB.conf[:ECHO] = nil
IRB.conf[:EVAL_HISTORY] = nil
IRB.conf[:HISTORY_FILE] = nil
IRB.conf[:IGNORE_EOF] = true
IRB.conf[:IGNORE_SIGINT] = true
IRB.conf[:INSPECT_MODE] = nil
IRB.conf[:IRB_NAME] = "irb"
IRB.conf[:IRB_RC] = nil
IRB.conf[:MATH_MODE] = false
IRB.c...
...onf[:PROMPT] = {....}
IRB.conf[:PROMPT_MODE] = :DEFAULT
IRB.conf[:SINGLE_IRB] = false
IRB.conf[:SAVE_HISTORY] = nil
IRB.conf[:USE_LOADER] = true
IRB.conf[:USE_READLINE] = nil
IRB.conf[:USE_TRACER] = true
IRB.conf[:VERBOSE] = true

それぞれの設定値の詳細については、IRB:...
...nf[:DEBUG_LEVEL] = 1
IRB.conf[:ECHO] = nil
IRB.conf[:EVAL_HISTORY] = nil
IRB.conf[:HISTORY_FILE] = nil
IRB.conf[:IGNORE_EOF] = true
IRB.conf[:IGNORE_SIGINT] = true
IRB.conf[:INSPECT_MODE] = nil
IRB.conf[:IRB_NAME] = "irb"
IRB.conf[:IRB_RC] = nil
IRB.conf[:PROMPT] = {....}
IRB.con...
...f[:PROMPT_MODE] = :DEFAULT
IRB.conf[:SINGLE_IRB] = false
IRB.conf[:SAVE_HISTORY] = nil
IRB.conf[:USE_LOADER] = true
IRB.conf[:USE_READLINE] = nil
IRB.conf[:USE_TRACER] = true
IRB.conf[:VERBOSE] = true

それぞれの設定値の詳細については、IRB::Context を参照してくだ...
...:PROMPT_MODE] = :DEFAULT
IRB.conf[:SINGLE_IRB] = false
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:USE_LOADER] = true
IRB.conf[:USE_READLINE] = nil
IRB.conf[:USE_TRACER] = true
IRB.conf[:VERBOSE] = true

それぞれの設定値の詳細については、IRB::Context を参照してくだ...

メソッド呼び出し(super・ブロック付き・yield) (222.0)

メソッド呼び出し(super・ブロック付き・yield) * super * block * yield * block_arg * numbered_parameters * call_method

...ield)
* 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
//}

文法:

[式 `.'] 識別子 [`(' [[`*'] 式] ... [`&' 式] `)']
[式 `::'] 識別子 [`...
...ーライドしたメソッドを呼び出すには
super() と括弧を明示します。

//emlist[例][ruby]{
class Foo
def foo(arg=nil)
p arg
end

end


class Bar < Foo
def foo(arg)
super(5) # 5 を引数にして呼び出す
super(arg) # 5 を引数にして呼び出...
...しで呼び出す
end

end

Bar.new.foo 5
//}

===[a:block] ブロック付きメソッド呼び出し

//emlist[例][ruby]{
[1,2,3].each do |i| print i*2, "\n" end
[1,2,3].each {|i| print i*2, "\n" }
//}

文法:

method(arg1, arg2, ...) do [`|' 式 ... `|'] 式 ... end
method...
...メソッドを呼びだそうとすると、レシーバが nil の場合は
以下のように働きます。

* 引数の評価が行なわれない
* メソッド呼び出しが行われない
* nil を返す

レシーバが nil でない場合は通常のメソッド呼び出しが行わ...

Timeout.#timeout(sec, exception_class = nil) {|i| ... } -> object (185.0)

ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。

...::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がはいります。

また sec が 0 もしくは nil のときは制限時間なしで
ブロックを実行します。

@param sec タイムアウトする時間を秒数で指定します.
@param e...
...rand
y = rand
x**2 + y**2 < 1.0 ? min[0] += 1 : min[1] += 1
end

end


t = 5
min = [ 0, 0]
begin
Timeout.timeout(t){
calc_pi(min)
}
rescue Timeout::Error
puts "timeout"
end


print
f "%d: pi = %f\n", min[0] + min[1], min[0]*4.0/(min[0]+min[1])
#例...
...ムアウト
#!/usr/bin/env ruby

require 'timeout'

class MYError < Exception;end
begin
Timeout.timeout(5, MYError) {
sleep(30)
}
rescue MYError => err
puts "MYError"
puts err
end


=== 注意

timeout による割り込みは Thread によって実現されてい...

絞り込み条件を変える

<< 1 2 3 ... > >>