るりまサーチ

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

別のキーワード

  1. fiddle ruby_free
  2. rbconfig ruby
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

モジュール

キーワード

検索結果

<< < 1 2 >>

StringScanner#<<(str) -> self (156.0)

操作対象の文字列に対し str を破壊的に連結します。 マッチ記録は変更されません。

...記録は変更されません。

selfを返します。

@
param str 操作対象の文字列に対し str を破壊的に連結します。

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

s = StringScanner.new('test') # => #<StringScanner 0/4 @ "test">
s.scan(/\w(\w*)/) # => "test"
s[0]...
...# => "test"
s[1] # => "est"
s << ' string' # => #<StringScanner 4/11 "test" @ " stri...">
s[0] # => "test"
s[1] # => "est"
s.scan(/\s+/) # => " "
s.scan(/\w+/)...
...w に渡した文字列にも影響することがあります。

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

str = 'test'
s = StringScanner.new(str) # => #<StringScanner 0/4 @ "test">
s << ' string' # => #<StringScanner 0/11 @ "test ...">
str # => "test string"
//}...

String#append_as_bytes(*objects) -> self (155.0)

引数で与えたオブジェクトをバイト列として、self に破壊的に連結します。

...][ruby]{
s = "あ".b # => "\xE3\x81\x82"
s.encoding # => #<Encoding:BINARY (ASCII-8BIT)>
s.append_as_bytes("い") # => "\xE3\x81\x82\xE3\x81\x84"

# s << "い" では連結できない
s << "い" # => "incompatible character encodings: BINARY (ASCII-8BIT) and UTF-8 (E...
...ncoding::CompatibilityError)
//}

//emlist[引数で整数を渡す例][ruby]{
t = ""
t.append_as_bytes(0x61) # => "a"
t.append_as_bytes(0x3062) # => "ab"
//}

@
see String#<<, String#concat...

String#<<(other) -> self (134.0)

self に文字列 other を破壊的に連結します。 other が 整数である場合は other.chr(self.encoding) 相当の文字を末尾に追加します。

...other.chr(self.encoding) 相当の文字を末尾に追加します。

self を返します。

@
param other 文字列もしくは 0 以上の整数

//emlist[例][ruby]{
str = "string"
str.concat "XXX"
p str # => "stringXXX"

str << "YYY"
p str # => "stringXXXYYY"

str << 65 # 文字A...

Enumerable#lazy -> Enumerator::Lazy (125.0)

自身を lazy な Enumerator に変換したものを返します。

...評価を行う (つまり、配列ではな
くEnumeratorを返す) ように再定義されています。

* map/collect
* flat_map/collect_concat
* select/find_all
* reject
* grep
* take, take_while
* drop, drop_while
* zip (※一貫性のため、ブロックを渡さないケースの...
...azy)

以下はピタゴラス数 (a**2 + b**2 = c**2 を満たす自然数 a, b, c の組) を
列挙するプログラムです。

//emlist[例][ruby]{
def pythagorean_triples
(1..Float::INFINITY).lazy.flat_map {|z|
(1..z).flat_map {|x|
(x..z).select {|y|
x**2 + y**2 == z**2...
...数を表示する
p pythagorean_triples.take(10).force # takeはlazyなので、forceが必要です
p pythagorean_triples.first(10) # firstはeagerです
# 100より小さいピタゴラス数を表示する
p pythagorean_triples.take_while { |*, z| z < 100 }.force
//}

@
see Enumerator::Lazy...
<< < 1 2 >>