Skip to content

Commit 6639f14

Browse files
committedNov 8, 2013
Make Array#fetch exceptions compliant
1 parent b619097 commit 6639f14

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎opal/core/array.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,12 @@ def fetch(index, defaults = undefined, &block)
592592
return defaults;
593593
}
594594
595-
#{ raise IndexError, "Array#fetch" };
595+
if (self.length === 0) {
596+
#{raise IndexError, "index #{`original`} outside of array bounds: 0...0"}
597+
}
598+
else {
599+
#{raise IndexError, "index #{`original`} outside of array bounds: -#{`self.length`}...#{`self.length`}"};
600+
}
596601
}
597602
end
598603

0 commit comments

Comments
 (0)
Please sign in to comment.