Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/commonmeta/array.rb

Overview

turn array into hash or nil, depending on array size. Reverses Array.wrap, but uses self to allow chaining with Array.wrap

Instance Method Summary collapse

Instance Method Details

#unwrapObject



6
7
8
9
10
11
12
# File 'lib/commonmeta/array.rb', line 6

def unwrap
  case length
  when 0 then nil
  when 1 then first
  else self
  end
end