Class: Array

Inherits:
Object show all
Defined in:
lib/core_extensions.rb

Instance Method Summary collapse

Instance Method Details

#swap_indexes(a, b) ⇒ Object



57
58
59
60
61
# File 'lib/core_extensions.rb', line 57

def swap_indexes(a,b)
  temp = self.dup
  temp[a], temp[b] = temp[b], temp[a]
  temp
end

#swap_indexes!(a, b) ⇒ Object



63
64
65
66
# File 'lib/core_extensions.rb', line 63

def swap_indexes!(a,b)
  self[a], self[b] = self[b], self[a]
  self
end

#to_hObject



53
54
55
# File 'lib/core_extensions.rb', line 53

def to_h
  Hash[self]
end

#uniq?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/core_extensions.rb', line 49

def uniq?
  length == uniq.length
end