mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Handle negative indices
This commit is contained in:
parent
155e9ec81a
commit
cd86687dfb
1 changed files with 2 additions and 1 deletions
|
@ -31,8 +31,9 @@ module Spectator
|
|||
getter example_count = 0
|
||||
|
||||
def [](index : Int) : Example
|
||||
raise IndexError.new if index < 0
|
||||
offset = index
|
||||
offset += example_count if offset < 0
|
||||
raise IndexError.new if offset < 0 || offset >= example_count
|
||||
found = children.find do |child|
|
||||
count = child.example_count
|
||||
if offset < count
|
||||
|
|
Loading…
Reference in a new issue