Groovy web console

subscribe to the feed Subscribe
to this
site

findResults example

Published 3 months ago by askalski85 with tags groovy
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
class User {
  def name
  User (def name) {
    this.name = name
  }
}

def getUser(def name) {
    if (name == "Lucas") {
        return null
    }
    return new User(name)
}

def usersNames = ["Arek", "Lucas", "Kostiantyn"]


usersNames.findResults { name -> getUser(name) }