Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/lafcadio/util.rb
Instance Method Summary collapse
-
#only ⇒ Object
If this array has one element, returns that element; otherwise, raises an error.
Instance Method Details
#only ⇒ Object
If this array has one element, returns that element; otherwise, raises an error.
7 8 9 10 11 12 13 |
# File 'lib/lafcadio/util.rb', line 7 def only if size != 1 raise "Expected single-value Array but Array has #{ size } members" else first end end |