19 lines
405 B
GDScript
19 lines
405 B
GDScript
class_name RangeIterator extends Iterator
|
|
|
|
var _index: int
|
|
var _to: int
|
|
var _step: int
|
|
|
|
func _init(from: int, to: int, step: int = 1) -> void:
|
|
_index = from - 1
|
|
_to = to
|
|
_step = step
|
|
|
|
func clone() -> RangeIterator:
|
|
return RangeIterator.new(_index, _to, _step)
|
|
|
|
func next() -> Option:
|
|
if _index < _to:
|
|
_index += 1
|
|
return Option.some(_index)
|
|
else: return Option.none
|