Skip to content

Instantly share code, notes, and snippets.

@punneng
Last active May 11, 2018 09:52
Show Gist options
  • Select an option

  • Save punneng/71587989179fe9e34b466d22ec3d5114 to your computer and use it in GitHub Desktop.

Select an option

Save punneng/71587989179fe9e34b466d22ec3d5114 to your computer and use it in GitHub Desktop.
class Obj {
var v1
def doSomething() {
[1,2,3].forEach(i => {
this.v1 = i
this.v2 = random()
this.validate_with_instance_variable() // (1)
this.validate_with_passing_variable(i, this.v2) // (2)
})
}
// case (1)
def validate_with_instance_variable() {
// do something with this.v1 and this.v2
this.validate_other_case_with_instance_variable()
}
def validate_other_case_with_instance_variable() {
// do something with this.v1 and this.v2
}
// ------------
// case (2)
def validate_with_passing_variable(arg1, arg2) {
// do something with arg1 and arg2
this.validate_other_case_with_passing_variable(arg1, arg2)
}
def validate_other_case_with_passing_variable(arg1, arg2) {
// do something with arg1 and arg2
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment