Container Function ConPeek() in X++ Programming Language
Table of Content:
ConPeek()
Function
- The conPeek() is used to retrieve a specific element from a container.
- Syntax: anytype conPeek(container container, int number)
- container - The container to return an element from.
- number - The position of the element to return. Specify 1 to get the first element.
- Return value: The element in the container at the position specified by the number parameter. The conPeek function automatically converts the peeked item into the expected return type.
Example
static void JobConatinerExample1(Args _args) { // container declaration and initialization with 2 values container conatinerName = ["Hello World", 1234]; str charHolder; // conPeek() function returns the value being held in a specific position in the container. // (Note: It returns anyType) // Here printing 1st and 2nd values from conatinerName to info charHolder = conPeek(conatinerName, 1); info(strFmt("Container conPeek() values are :- %1, %2", charHolder, conPeek(conatinerName, 2))); }
Output
Info Message (05:17:28 am) Container conPeek() values are :- Hello World, 1234