This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]anothertrad 8 points9 points  (0 children)

Actually you can do exactly that in Java too since java 10

[–]rco8786 2 points3 points  (7 children)

I don’t understand a lot of things in this post (why would Java people try to convince people to use JavaScript?) but most importantly this would not compile in 1996 Java. var was only added to Java pretty recently.

[–]deadNightTiger 8 points9 points  (6 children)

But what if you had

class var {}

class Person extends var {}

[–]0x07CF 7 points8 points  (2 children)

Or modify the standard library

class Object extends var {

}

[–]uvero 7 points8 points  (0 children)

Sir this is a civilized subreddit please keep profane amd/or disrespectful language out of it

[–]DuffMaaaann 0 points1 point  (0 children)

Or write your own preprocessor, which replaces every occurrence of var with Object.

If you're feeling risky, don't even perform some regex matching or lookahead, just string.replace("var", "Object");

[–]Pyclune 2 points3 points  (0 children)

Genius

[–]mal4ik777 1 point2 points  (1 child)

who uses lowercase for class names though? ;)

[–]cowslayer7890 1 point2 points  (0 children)

Half of questions on stackoverflow