Skip to content

Commit

Permalink
- Generalized the Array.index() and Array.rindex() to work with array…
Browse files Browse the repository at this point in the history
…s containing any kind of objects.

- Removed the String.=() and Number.=() methods, as they no longer worked anyway.
  • Loading branch information
trizen committed Nov 19, 2015
1 parent 6f26474 commit d9b1608
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
10 changes: 4 additions & 6 deletions lib/Sidef/Types/Array/Array.pm
Original file line number Diff line number Diff line change
Expand Up @@ -666,10 +666,9 @@ package Sidef::Types::Array::Array {
return Sidef::Types::Number::Number->new(-1);
}

state $method = '=';
foreach my $i (0 .. $#{$self}) {
$self->[$i]->$method($obj)
&& return Sidef::Types::Number::Number->new($i);
$self->[$i] eq $obj
and return Sidef::Types::Number::Number->new($i);
}

return Sidef::Types::Number::Number->new(-1);
Expand All @@ -693,10 +692,9 @@ package Sidef::Types::Array::Array {
return Sidef::Types::Number::Number->new(-1);
}

state $method = '=';
for (my $i = $#{$self} ; $i >= 0 ; $i--) {
$self->[$i]->$method($obj)
&& return Sidef::Types::Number::Number->new($i);
$self->[$i] eq $obj
and return Sidef::Types::Number::Number->new($i);
}

return Sidef::Types::Number::Number->new(-1);
Expand Down
1 change: 0 additions & 1 deletion lib/Sidef/Types/Number/Number.pm
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,6 @@ package Sidef::Types::Number::Number {
*{__PACKAGE__ . '::' . '>='} = \≥
*{__PACKAGE__ . '::' . ''} = \≥
*{__PACKAGE__ . '::' . '=='} = \&eq;
*{__PACKAGE__ . '::' . '='} = \&eq;
*{__PACKAGE__ . '::' . '!='} = \≠
*{__PACKAGE__ . '::' . ''} = \≠
*{__PACKAGE__ . '::' . '..'} = \&array_to;
Expand Down
1 change: 0 additions & 1 deletion lib/Sidef/Types/String/String.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,6 @@ package Sidef::Types::String::String {
*{__PACKAGE__ . '::' . '++'} = \&inc;
*{__PACKAGE__ . '::' . '-'} = \&subtract;
*{__PACKAGE__ . '::' . '=='} = \=
*{__PACKAGE__ . '::' . '='} = \=
*{__PACKAGE__ . '::' . '!='} = \≠
*{__PACKAGE__ . '::' . ''} = \≠
*{__PACKAGE__ . '::' . '>'} = \>
Expand Down

0 comments on commit d9b1608

Please sign in to comment.