Questions tagged [enumerable]

"enumerable" refers to an ordering scheme that enables items in a set, sequence or collection to be readily addressed or traversed.

Enumerable is a Ruby module which can be included in other Ruby classes in order to allow iteration via #map/#collect, #select, #each, and so on.

Enumerable also manifests as the class Enumerator (documentation), which is returned when an iteration method is called without a block (e.g., array.each instead of array.each { |x| puts x }).

Enumerable objects may also utilize chained iteration, e.g., array.each.with_indices instead of array.each_with_indices.

Ruby 2.0 also introduces the concept of lazy enumeration.

In .NET, Enumerable is the class that wraps most common LINQ extension methods.

603 questions
-5
votes
1 answer

If I have a collection of hashes with the same key and values, how do I add another value together?

I've assigned these rows to hashes: other_id: 1,amount: 9290,id: 1 other_id: 2,amount: 2262,id: 1 other_id: 3,amount: 9588,id: 2 other_id: 4,amount: 1634,id: 2 How do I add together the amount values for a specific id, so for id: 1, I need the…
purry
  • 62
  • 1
  • 10
-5
votes
1 answer

What is shortest in code terms way for given N to output strings "1", "1 2"... "1 2 ... N"?

What is shortest in code terms way for given N (int) to output List out; containing strings "1", "1 2"... "1 2 ... N"? For N == 3 out would contain "1"; "1 2"; "1 2 3"
DuckQueen
  • 772
  • 10
  • 62
  • 134
1 2 3
40
41