Nav

every

every(Array<T>, (T) → Boolean): Boolean

Returns true if every element of the list matches the condition. It stops the iterations after the first negative evaluation. .Transform


        
     
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
%dw 2.0
import * from dw::core::Arrays
var arr0: Array<Number> = []
output application/json
---
{
  ok: [
    [1,2,3] some (($ mod 2) == 0),
    [1,2,3] some (($ mod 2) == 1),
    [1,2,3,4,5,6,7,8] some (log('should stop at 2 ==', $) == 2),
    [1,2,3] some ($ == 1),
    [1,1,1] every ($ == 1),
    [1,1,1] some ($ == 1),
    [1] every ($ == 1),
    [1] some ($ == 1),
  ],
  err: [
    [1,2,3] every ((log('should stop at 2 ==', $) mod 2) == 1),
    [1,2,3] some ($ == 100),
    [1,1,0] every ($ == 1),
    [0,1,1,0] every (log('should stop at 0 ==', $) == 1),
    [1] some ($ == 2),
    [1,2,3] every ($ == 1),
    arr0 every true,
    arr0 some true,
    arr0 some ($ is Number)
  ]
}
Output

        
     
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
  "ok": [
    true,
    true,
    true,
    true,
    true,
    true,
    true,
    true
  ],
  "err": [
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false
  ]
}

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.

+