るりまサーチ

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

別のキーワード

  1. _builtin each
  2. _builtin each_line
  3. prime each
  4. each
  5. tsort tsort_each

ライブラリ

クラス

モジュール

キーワード

検索結果

<< < ... 2 3 4 >>

Object#enum_for(method = :each, *args) -> Enumerator (7.0)

Enumerator.new(self, method, *args) を返します。

...かシンボルです。
@param args 呼び出すメソッドに渡される引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1...

Object#enum_for(method = :each, *args) {|*args| ... } -> Enumerator (7.0)

Enumerator.new(self, method, *args) を返します。

...かシンボルです。
@param args 呼び出すメソッドに渡される引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1...

Object#to_enum(method = :each, *args) -> Enumerator (7.0)

Enumerator.new(self, method, *args) を返します。

...かシンボルです。
@param args 呼び出すメソッドに渡される引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1...

Object#to_enum(method = :each, *args) {|*args| ... } -> Enumerator (7.0)

Enumerator.new(self, method, *args) を返します。

...かシンボルです。
@param args 呼び出すメソッドに渡される引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1...

String#sum(bits = 16) -> Integer (7.0)

文字列の bits ビットのチェックサムを計算します。

...文字列の bits ビットのチェックサムを計算します。

以下と同じです。

//emlist[][ruby]{
def sum(bits)
sum = 0
each_byte
{|c| sum += c }
return 0 if sum == 0
sum & ((1 << bits) - 1)
end
//}

例えば以下のコードで UNIX System V の
sum(1) コマンドと同...

絞り込み条件を変える

String#unpack(template) -> Array (7.0)

Array#pack で生成された文字列を テンプレート文字列 template にしたがってアンパックし、 それらの要素を含む配列を返します。

...: 文字列を数値(文字コード)の配列に変換する例
//emlist[][ruby]{
"Ruby".unpack('C*') # => [82, 117, 98, 121]

a = []
"Ruby".each_byte {|c| a << c}
a # => [82, 117, 98, 121]
//}

: "x" でヌルバイトを埋めることができる
//emlist[][ruby]{
[82, 117, 98, 121].pack(...
<< < ... 2 3 4 >>