how to accept multiple parameters from returning function in groovy

后端 未结 3 1287
终归单人心
终归单人心 2020-12-24 10:40

I want to return multiple values from a function written in groovy and receive them , but i am getting an error

class org.codehaus.groovy.ast.expr.Lis

3条回答
  •  旧巷少年郎
    2020-12-24 11:04

    You can declare and assign the variables in which the return values are stored in one line like this, which is a slightly more compact syntax than that used in Justin's answer:

    def (int a, int b) = f1(22)
    

    In your particular case you may not be able to use this because one of the variables passed to f1 is also used to store a return value

提交回复
热议问题