这是【Dart 教程系列第 16 篇】,如果觉得有用的话,欢迎关注专栏。
Dart 获取指定元素在数组中的索引,用 indexOf()
方法或者 lastIndexOf()
方法,其中 indexOf 方法是从前往后找,lastIndexOf 方法是从后往前找,下面分别举例说明。
indexOf
方法的源代码定义如下
int indexOf(E element, [int start = 0
这是【Dart 教程系列第 16 篇】,如果觉得有用的话,欢迎关注专栏。
Dart 获取指定元素在数组中的索引,用 indexOf()
方法或者 lastIndexOf()
方法,其中 indexOf 方法是从前往后找,lastIndexOf 方法是从后往前找,下面分别举例说明。
indexOf
方法的源代码定义如下
int indexOf(E element, [int start = 0