Skip to content

Commit 6784100

Browse files
refactoring index_of
1 parent 2cc2736 commit 6784100

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/IndexOf.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ function index_of(iterable $haystack, $element, bool $strict = true)
1818
}
1919

2020
foreach ($haystack as $index => $value) {
21-
if (($strict && $element === $value) || (!$strict && $element == $value)) {
21+
if ($strict && $element === $value) {
22+
return $index;
23+
}
24+
25+
if (!$strict && $element == $value) {
2226
return $index;
2327
}
2428
}

0 commit comments

Comments
 (0)