Skip to content

Commit

Permalink
that was quite easy!
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonak-Adipta-Kalita committed Sep 9, 2023
1 parent df7889d commit 2a08a38
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,12 @@ func (ao *Array) InvokeMethod(method string, args ...Object) Object {
return &Error{Message: "Missing argument to find()!"}
}

// TODO - Allow finding non-strings.
arg := args[0].Inspect()
result := -1
for idx, entry := range ao.Elements {
if entry.Type() == STRING_OBJ {
if entry.(*String).Value == arg {
result = idx
break
}
if entry.Inspect() == arg {
result = idx
break
}
}
return &Integer{Value: int64(result)}
Expand Down

0 comments on commit 2a08a38

Please sign in to comment.