Builds extensions. Valid types of extensions are extconf.rb files, configure scripts and rakefiles or mkrf_conf files.
@return [Symbol] The name of the action.
Adds the given action to the log, running the action @param [DependencyGraph] graph @param [Action] action @return The value returned by ‘action.up`
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
provides a unified clone
operation, for REXML::XPathParser
to use across multiple Object
types
Produces a shallow copy of obj—the instance variables of obj are copied, but not the objects they reference. clone
copies the frozen (unless :freeze keyword argument is given with a false value) and tainted state of obj. See also the discussion under Object#dup
.
class Klass attr_accessor :str end s1 = Klass.new #=> #<Klass:0x401b3a38> s1.str = "Hello" #=> "Hello" s2 = s1.clone #=> #<Klass:0x401b3998 @str="Hello"> s2.str[1,4] = "i" #=> "i" s1.inspect #=> "#<Klass:0x401b3a38 @str=\"Hi\">" s2.inspect #=> "#<Klass:0x401b3998 @str=\"Hi\">"
This method may have class-specific behavior. If so, that behavior will be documented under the #initialize_copy
method of the class.
Deprecated method that is equivalent to taint
.
Deprecated method that is equivalent to tainted?
.