lib/core/facets/array/only.rb in facets-2.9.3 vs lib/core/facets/array/only.rb in facets-3.0.0

- old
+ new

@@ -15,12 +15,23 @@ # # CREDIT: Gavin Sinclair, Noah Gibbs def only unless size == 1 - raise IndexError, "Array#only called on non-single-element array" + raise IndexError, "not the only element of array" end first end + # Does this Array have only one element? + # + # TODO: While clearly this goes along with the regular #only method, + # the name doesn't seem quite right. Perhaps rename to #lonely. + # + # CREDIT: Lavir the Whiolet + # + def only? + size == 1 + end + end