E0070#
Warning name: deprecated_for_in_method
Deprecated method name for for .. in iteration.
MoonBit now looks for iter or iter2 when a value is used as the source of a
for .. in loop. The old method names iterator and iterator2 still work for
now, but they are deprecated.
Erroneous example#
///|
priv struct Bag {}
///|
fn Bag::iterator(_self : Bag) -> Iter[Int] {
[1, 2, 3].iter()
}
///|
fn sum(bag : Bag) -> Int {
let mut total = 0
for value in bag {
total = total + value
}
total
}
///|
test {
inspect(sum(Bag::{ }), content="6")
}
Suggestion#
Rename iterator to iter, or iterator2 to iter2.
///|
priv struct Bag {}
///|
fn Bag::iter(_self : Bag) -> Iter[Int] {
[1, 2, 3].iter()
}
///|
fn sum(bag : Bag) -> Int {
let mut total = 0
for value in bag {
total = total + value
}
total
}
///|
test {
inspect(sum(Bag::{ }), content="6")
}