Skip to content

Instantly share code, notes, and snippets.

@RomanSaveljev
Created November 24, 2015 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RomanSaveljev/71ed29b0df3eb306485c to your computer and use it in GitHub Desktop.
Save RomanSaveljev/71ed29b0df3eb306485c to your computer and use it in GitHub Desktop.
Groovy bug
class A {
A() {
func()
}
void func() {
}
}
void func() {
def t = false
def a = new A() {
@Override
void func() {
assert t != null
println "t is ${t}"
}
}
//t = true
a.func()
}
func()
package com.github.RomanSaveljev.modemchat;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
private static class A {
A() {
func();
}
void func() {
}
}
static void func() {
Boolean t = false;
A a = new A() {
@Override
void func() {
assert t != null;
System.out.println(t.toString());
//println "t is ${t}"
}
};
//t = true
a.func();
}
public static void main (String[] args) throws java.lang.Exception
{
System.out.println("MOOO");
func();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment