I thought this was cool
// This was the closest i could get in java.// still confused about the terminology 'SingletonMethod'
public class SingletonMethodJava {
void theOnlyMethod(){
System.out.println("theOnlyMethod");
}
public static void main(String[] args){
new SingletonMethodJava(){
void addedOneMoreMethod(){
System.out.println("addedOneMoreMethod");
}
}.addedOneMoreMethod();
}
}But isn't this cooler ?
class SingletonMethodRuby
def theOnlyMethod
puts "theOnlyMethod";
end
end
singleton_method = SingletonMethodRuby.new
def singleton_method.addedOneMoreMethod
puts "addedOneMoreMethod";
end
singleton_method.addedOneMoreMethod








0 comments:
Post a Comment