restrict list index to integer

This commit is contained in:
2020-03-09 13:47:57 +02:00
parent a70e510548
commit 62d8d92b50
2 changed files with 4 additions and 0 deletions

View File

@ -53,6 +53,7 @@ module Parfait
# set the value at index.
# Lists start from index 0
def get( index )
raise "Only integers, #{index.class}" unless index.is_a?(::Integer)
raise "Only positive indexes, #{index}" if index < 0
if index >= data_length
return nil unless @next_list