groovy - How to find in a collection? -


i have following variable , collection

def currentproduct = "item1" def currentpresentation = "crema" def curentmeasure = "1ml"  def items = [[product:"item1", presentation:"crema", measure:"1ml", quantity:5, total:77.50], [product:"item1", presentation:"spray", measure:"habracadabra", quantity:9, total:158.40]]  

i need quantity value in map product, presentation , measure equal variable values, can me

thanks time

here go:

items.find { it.product == currentproduct && it.presentation == currentpresentation && it.measure == curentmeasure}?.quantity 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -