LANG-1402: refactored to return default value on negative index
This commit is contained in:
parent
625fbccaa9
commit
7721302ae5
|
@ -8700,7 +8700,7 @@ public class ArrayUtils {
|
|||
}
|
||||
|
||||
if(index < 0 ){
|
||||
index = 0;
|
||||
return defaultReturn;
|
||||
}
|
||||
|
||||
return array[index];
|
||||
|
|
|
@ -5125,7 +5125,7 @@ public class ArrayUtilsTest {
|
|||
assertEquals("Test", ArrayUtils.get(array, 10, "Test"));
|
||||
|
||||
//negative index
|
||||
assertEquals("Hello World", ArrayUtils.get(array, -1));
|
||||
assertEquals("Default", ArrayUtils.get(array, -1, "Default"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue