Search code examples
jolie

How to create a random index in Jolie


I am starting to play around with Jolie I was looking for a way to randomise an index What include do I need to use, can you create a random integer number?


Solution

  • Thanks for the question and interest in Jolie.

    1. Can you create a random integer number? Not directly
    2. What include do I need to use? math.iol

    Here my simple code

    include "math.iol"
    include "console.iol"
    
    main{
          random@Math()(randomResult);
          randomIndex= int (randomResult*10); // 10 is the maximum index size
          println@Console(randomIndex)()
     }
    

    I hope this helps B