undesriable type redundancy required
Brought to you by:
bonniot
// What I have to write is this:
Env makeEnv(List<(String, String)> initList) {
var m = new Env();
var String key;
var String value;
for ( (String, String) item : initList) {
(key, value) = item;
m.put(key, value);
}
return m;
}
// What I want to write
Env makeEnv(List<(String, String)> initList) {
var m = new Env();
for ( var (key, value) : initList) m.put(key, value);
return m;
}
// That is. Why shouldn't I be able to introduce a whole
tuple
// of variables simultaneously, and have their types
inferred
// the same as if they were top level variables. E.g.,
// var (a, b) = ....expression of return type (String,
Int)...
// The way I have to do this currently feels too
redundant to me.
Logged In: YES
user_id=688815
I agree type inference should be made work for tuples too.
(moved to feature requests)