Browse Source

array write access on Map should return the value so it can be chained

Simon Krajewski 12 years ago
parent
commit
a1370adec2
2 changed files with 7 additions and 3 deletions
  1. 3 2
      std/Map.hx
  2. 4 1
      tests/unit/unitstd/Map.unit.hx

+ 3 - 2
std/Map.hx

@@ -118,8 +118,9 @@ abstract Map< K, V > (IMap< K, V > ) {
 		return this.get(k);
 	}
 	
-	@:arrayAccess public inline function arrayWrite(k:K, v:V):Void {
-		this.set(k,v);
+	@:arrayAccess public inline function arrayWrite(k:K, v:V):V {
+		this.set(k, v);
+		return v;
 	}
 	
 	@:to static inline function toStringMap(t:IMap < String, V > ):StringMap<V> {

+ 4 - 1
tests/unit/unitstd/Map.unit.hx

@@ -150,4 +150,7 @@ map["foo"] == 14;
 map["foo"] *= map["foo"] + 2;
 map["foo"] == 224;
 map["f" + "o" + "o"] -= 223;
-map[(function(s) return s + "o")("fo")] == 1;
+map[(function(s) return s + "o")("fo")] == 1;
+map["bar"] = map["foo"] = 9;
+map["bar"] == 9;
+map["foo"] == 9;