--- Title: Foreach alwaysopen: false categories: - docs - operate - stack description: For each record in the pipe, runs some operations. linkTitle: foreach weight: 50 --- ```java public GearsBuilder foreach​( gears.operations.ForeachOperation foreach) ``` Defines a set of operations to run for each record in the pipe. ## Parameters | Name | Type | Description | |------|------|-------------| | foreach | ForeachOperation | The set of operations to run for each record | ## Returns Returns a GearsBuilder object with a new template type. ## Example For each person hash, add a new full_name field that combines their first and last names: ```java GearsBuilder.CreateGearsBuilder(reader).foreach(r->{ String firstName = r.getHashVal().get("first_name"); String lastName = r.getHashVal().get("last_name"); r.getHashVal().put("full_name", firstName + lastName); }); ```