java2xtend icon indicating copy to clipboard operation
java2xtend copied to clipboard

Method arguments are getting reassigned in xtend code

Open abies opened this issue 11 years ago • 0 comments

public class Test {
    public void m(int arg) {
        arg = 5;
        System.out.println(arg);
    }
}

generates

class Test {
  def m(  int arg){
    arg=5
    println(arg)
  }
}

which fails at assignment of 5 to arg. Solution would be to create artificial variable at the very start of method, rename method arg to _arg and then use variable later in the method (of course, only if this is needed, too much visual noise otherwise)

abies avatar Jun 04 '13 12:06 abies