Create a new DefNode
node
Create a new EmbeddedStatementsNode
node
Create a new FindPatternNode
node
Create a new FloatNode
node
Create a new GlobalVariableOperatorWriteNode
node
Create a new HashPatternNode
node
Create a new IfNode
node
Create a new ImaginaryNode
node
Create a new IndexOperatorWriteNode
node
Create a new InterpolatedStringNode
node
Create a new InterpolatedSymbolNode
node
Create a new InterpolatedXStringNode
node
Create a new LocalVariableOperatorWriteNode
node
Create a new RationalNode
node
Create a new SelfNode
node
Create a new SplatNode
node
Create a new StatementsNode
node
Create a new UndefNode
node
Generate a string that randomly draws from a source array of characters.
The argument source specifies the array of characters from which to generate the string. The argument n specifies the length, in characters, of the string to be generated.
The result may contain whatever characters are in the source array.
require 'random/formatter' prng.choose([*'l'..'r'], 16) #=> "lmrqpoonmmlqlron" prng.choose([*'0'..'9'], 5) #=> "27309"
Simple deprecation method that deprecates name
by wrapping it up in a dummy method. It warns on each call to the dummy method telling the user of repl
(unless repl
is :none) and the year/month that it is planned to go away.
A Zlib::Inflate#inflate
wrapper
Iterates over array indexes.
When a block given, passes each successive array index to the block; returns self
:
a = [:foo, 'bar', 2] a.each_index {|index| puts "#{index} #{a[index]}" }
Output:
0 foo 1 bar 2 2
Allows the array to be modified during iteration:
a = [:foo, 'bar', 2] a.each_index {|index| puts index; a.clear if index > 0 }
Output:
0 1
When no block given, returns a new Enumerator:
a = [:foo, 'bar', 2] e = a.each_index e # => #<Enumerator: [:foo, "bar", 2]:each_index> a1 = e.each {|index| puts "#{index} #{a[index]}"}
Output:
0 foo 1 bar 2 2
Related: each
, reverse_each
.