ソースを参照

added first()

Nicolas Cannasse 19 年 前
コミット
44766031ea
1 ファイル変更9 行追加0 行削除
  1. 9 0
      std/List.hx

+ 9 - 0
std/List.hx

@@ -65,6 +65,15 @@ class List<T> {
 		h = cons(item,h);
 	}
 
+	public function first() : T {
+		return switch h {
+		case empty:
+			null;
+		case cons(it,h):
+			it;
+		}
+	}
+
 	public function pop() : T {
 		return switch h {
 		case empty: