Sensors::Chips
Inherits Array < Comparable < Indexable::Mutable < Indexable < Enumerable < Iterable < Reference < Object
Class methods
all
Sourceeach(match : Chip, &block : Chip -> _) : Void
Sourceeach
Calls the given block once for each element in self, passing that
element as a parameter.
a = ["a", "b", "c"]
a.each { |x| print x, " -- " }
produces:
a -- b -- c --
each_with_index(match : Chip, &block : Int32, Chip -> _) : Void
Sourceeach_with_index
Iterates over the collection, yielding both the elements and their index.
["Alice", "Bob"].each_with_index do |user, i|
puts "User ##{i}: #{user}"
end
Prints:
User # 0: Alice
User # 1: Bob
Accepts an optional offset parameter, which tells it to start counting from there. So, a more human friendly version of the previous snippet would be:
["Alice", "Bob"].each_with_index(1) do |user, i|
puts "User ##{i}: #{user}"
end
Which would print:
User # 1: Alice
User # 2: Bob
matching(match : Chip)
Source