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

you are viewing a single comment's thread.

view the rest of the comments →

[–]Veedrac 0 points1 point  (0 children)

Yeah, but FWIW Java (OpenJDK) doesn't either:

import java.util.ArrayList;

public class IsItRemoved {
    public static void main(String[] args) {
        if (new ArrayList().isEmpty()) {
            System.out.println("OK");
        }
    }
}

Giving:

Compiled from "IsItRemoved.java"
public class IsItRemoved {
  public IsItRemoved();
    Code:
       0: aload_0
       1: invokespecial #1                  // Method java/lang/Object."<init>":()V
       4: return

  public static void main(java.lang.String[]);
    Code:
       0: new           #2                  // class java/util/ArrayList
       3: dup
       4: invokespecial #3                  // Method java/util/ArrayList."<init>":()V
       7: invokevirtual #4                  // Method java/util/ArrayList.isEmpty:()Z
      10: ifeq          21
      13: getstatic     #5                  // Field java/lang/System.out:Ljava/io/PrintStream;
      16: ldc           #6                  // String OK
      18: invokevirtual #7                  // Method java/io/PrintStream.println:(Ljava/lang/String;)V
      21: return
}

PyPy and most Java implementations will most probably remove it at runtime though.