[].where not a list

Dart VM version: 1.24.3 (Wed Dec 13 23:26:59 2017) on “macos_x64”

the code:

final List<int> list = [1,3,4];
final List<int> res = list.where((i) => true);

fails runtime:

type 'WhereIterable<int>' is not a subtype of type 'List<int>' 

method where:

Iterable<E> where(bool test(E element)) => new WhereIterable<E>(this, test);

interface Iterable:

abstract class Iterable<E> {...}

expected behavior:

compile time error.

Author: Fantashit

1 thought on “[].where not a list

Comments are closed.