Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Streamline Buf.at_pos + add error for Inf/NaN
  • Loading branch information
lizmat committed Jan 12, 2015
1 parent 6ba20d0 commit 72228a6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/core/Buf.pm
Expand Up @@ -22,14 +22,16 @@ my role Blob[::T = uint8] does Positional[T] does Stringy is repr('VMArray') is
self.new(@values)
}

multi method at_pos(Blob:D: $i) {
nqp::atpos_i(self, $i.Int)
multi method at_pos(Blob:D: int \pos) {
nqp::atpos_i(self, pos);
}
multi method at_pos(Blob:D: Int $i) {
nqp::atpos_i(self, $i)
multi method at_pos(Blob:D: Int \pos) {
nqp::atpos_i(self, nqp::unbox_i(pos));
}
multi method at_pos(Blob:D: int $i) {
nqp::atpos_i(self, $i)
multi method at_pos(Blob:D: \pos) {
X::Item.new(aggregate => self, index => pos).throw
if nqp::istype(pos,Num) && nqp::isnanorinf(pos);
nqp::atpos_i(self, nqp::unbox_i(pos.Int));
}

multi method Bool(Blob:D:) {
Expand Down

0 comments on commit 72228a6

Please sign in to comment.