# Loop inside exec function

**URL:** <https://community.gatling.io/t/loop-inside-exec-function/4217>\
**Category:** Gatling (Open-Source)\
**Created:** [March 7, 2018, 5:08pm UTC](https://community.gatling.io/t/loop-inside-exec-function/4217 "2018-03-07T17:08:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![FM1](https://avatars.discourse-cdn.com/v4/letter/f/9fc29f/32.png) [@FM1](https://community.gatling.io/u/FM1)\
**Post date:** [March 7, 2018, 5:08pm UTC](https://community.gatling.io/t/loop-inside-exec-function/4217/1 "2018-03-07T17:08:17Z")

</div>

Hello Guys,

I couldn’t find anything about this in the documentation, I am wondering if we can **loop within the exec** function in Gatling, as in **looping over a check**.

**What I want to achieve :**

`  
def postOrder(shipmentListTwoProducts: ShipmentList) = {

exec({  
http(“POST Order”)  
.post(applicationConf.getString(“pathPostOrder”))  
// I want to loop here over shipmentListTwoProducts.shipmentList that s=is an array, so I want to call the check as many times as there are items in the array each time // passing a different variable to shipmentListMappingChecks method  
.check(  
ShipmentListChecks.shipmentListMappingChecks(  
index): \_\*)  
})  
}

`
