Builds extensions. Valid types of extensions are extconf.rb files, configure scripts and rakefiles or mkrf_conf files.
Creates a string representation of self
.
[ "a", "b", "c" ].to_s #=> "[\"a\", \"b\", \"c\"]"
Prepends objects to the front of self
, moving other elements upwards. See also Array#shift
for the opposite effect.
a = [ "b", "c", "d" ] a.unshift("a") #=> ["a", "b", "c", "d"] a.unshift(1, 2) #=> [ 1, 2, "a", "b", "c", "d"]
Returns a new array containing the items in self
for which the given block is not true
. The ordering of non-rejected elements is maintained.
See also Array#delete_if
If no block is given, an Enumerator
is returned instead.
Deletes every element of self
for which the block evaluates to true
, if no changes were made returns nil
.
The array may not be changed instantly every time the block is called.
See also Enumerable#reject
and Array#delete_if
.
If no block is given, an Enumerator
is returned instead.
Returns true
if the given object
is present in self
(that is, if any element ==
object
), otherwise returns false
.
a = [ "a", "b", "c" ] a.include?("b") #=> true a.include?("z") #=> false
Returns a new array by removing duplicate values in self
.
If a block is given, it will use the return value of the block for comparison.
It compares values using their hash
and eql?
methods for efficiency.
self
is traversed in order, and the first occurrence is kept.
a = [ "a", "a", "b", "b", "c" ] a.uniq # => ["a", "b", "c"] b = [["student","sam"], ["student","george"], ["teacher","matz"]] b.uniq { |s| s.first } # => [["student", "sam"], ["teacher", "matz"]]
Removes duplicate elements from self
.
If a block is given, it will use the return value of the block for comparison.
It compares values using their hash
and eql?
methods for efficiency.
self
is traversed in order, and the first occurrence is kept.
Returns nil
if no changes are made (that is, no duplicates are found).
a = [ "a", "a", "b", "b", "c" ] a.uniq! # => ["a", "b", "c"] b = [ "a", "b", "c" ] b.uniq! # => nil c = [["student","sam"], ["student","george"], ["teacher","matz"]] c.uniq! { |s| s.first } # => [["student", "sam"], ["teacher", "matz"]]
Returns a copy of self
with all nil
elements removed.
[ "a", nil, "b", nil, "c", nil ].compact #=> [ "a", "b", "c" ]
Removes nil
elements from the array.
Returns nil
if no changes were made, otherwise returns the array.
[ "a", nil, "b", nil, "c" ].compact! #=> [ "a", "b", "c" ] [ "a", "b", "c" ].compact! #=> nil
Returns the number of elements.
If an argument is given, counts the number of elements which equal obj
using ==
.
If a block is given, counts the number of elements for which the block returns a true value.
ary = [1, 2, 4, 2] ary.count #=> 4 ary.count(2) #=> 2 ary.count { |x| x%2 == 0 } #=> 3
provides a unified clone
operation, for REXML::XPathParser
to use across multiple Object+ types
Returns a string containing the representation of big radix base (2 through 36).
12345654321.to_s #=> "12345654321" 12345654321.to_s(2) #=> "1011011111110110111011110000110001" 12345654321.to_s(8) #=> "133766736061" 12345654321.to_s(16) #=> "2dfdbbc31" 78546939656932.to_s(36) #=> "rubyrules"
Returns a complex object which denotes the given rectangular form.
Complex.rectangular(1, 2) #=> (1+2i)
Returns a complex object which denotes the given rectangular form.
Complex.rectangular(1, 2) #=> (1+2i)
Returns the value as a string for inspection.
Complex(2).inspect #=> "(2+0i)" Complex('-8/6').inspect #=> "((-4/3)+0i)" Complex('1/2i').inspect #=> "(0+(1/2)*i)" Complex(0, Float::INFINITY).inspect #=> "(0+Infinity*i)" Complex(Float::NAN, Float::NAN).inspect #=> "(NaN+NaN*i)"
Always returns the string “nil”.
Returns an array; [num, 0].