Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method

Etc::Group.each

() -> untyped
Etc::Group.each { |group| block } → Etc::Group
Etc::Group.each → Enumerator

Iterates for each entry in the /etc/group file if a block is given.

If no block is given, returns the Enumerator.

The code block is passed a Group struct.

Example:

Example
require 'etc'

Etc::Group.each {|g|
  puts g.name + ": " + g.mem.join(', ')
}

Etc::Group.collect {|g| g.name}
Etc::Group.select {|g| !g.mem.empty?}
also in 4.0 · 3.4 · 3.3 · 3.2