fromTo
fromTo(a: Integer, b: Integer) : List<Integer>
Returns an ordered list of consecutive integers from a to b (inclusive). The list is in ascending order.
- For example,
fromTo(1, 3)returns[1, 2, 3]. - If the second argument is smaller than the first, as in
fromTo(3, 1), the returned value is the empty list.
fromTo(a: IpAddress, b: IpAddress) : List<IpAddress>
A list of IP addresses in a range can be constructed with fromTo(a, b), which equals the list of IP addresses starting
from a and ending with b. For example:
fromTo(ipAddress("1.2.2.254"), ipAddress("1.2.3.1"))is same as[1.2.2.254, 1.2.2.255, 1.2.3.0, 1.2.3.1]fromTo(ipAddress("2001:0db8:85a3:0000:0000:8a2e:0370:fffe"), ipAddress("2001:0db8:85a3:0000:0000:8a2e:0371:001"))is same as[2001:0db8:85a3:0000:0000:8a2e:0370:fffe, "2001:0db8:85a3:0000:0000:8a2e:0370:ffff, 2001:0db8:85a3:0000:0000:8a2e:0371:0, 2001:0db8:85a3:0000:0000:8a2e:0371:1].
If the second argument is smaller than the first, as in fromTo(ipAddress("1.2.2.4"), ipAddress("0.0.0.0")), the
returned value is the empty list.
This function will raise an error:
- if
aandbare not of same IP address family. For example,fromTo(ipAddress("1.2.2.254"), ipAddress ("2001:0db8:85a3:0000:0000:8a2e:0370:fffe")). - if number of IP addressese between
aandbis2147483647or greater.
See also
Guides
- Collections - Working with ordered lists
- Integer
- IpAddress
Functions
- ipAddress - Create IP address from string