Construct 3 r311

You're viewing a single comment in a conversation. View all the comments
  • 1 Comments

  • Order by
  • chooseindex enriches the usage of choose. But There is difference between chooseindex and tokenat, tokenat only needs to pass in 1 string as a parameter, while chooseindex needs multiple parameter, Their usage scenarios are very different.

    ▶ choose

    choose("Hey, how are you?", "Welcome!", "Nice to meet you!", "Hi, come in.")

    ▶ chooseindex

    chooseindex(int(random(4)), "Hey, how are you?", "Welcome!", "Nice to meet you!", "Hi, come in.")

    ▶ tokenat

    tokenat("Hey, how are you?;Welcome!;Nice to meet you!;Hi, come in.", int(random(4)), ";")

    ▶ ternary operator

    variable=1 ? "Hey, how are you?" : variable=2 ? "Welcome!" : variable=3 ? "Nice to meet you!" : variable=4 ? "Hi, come in." : ""

    ▶ Array

    Array.At(0, int(random(3)))

    ---------

    chooseindex(int(random(3)), array1.at(0,int(random(3))), array2.at(0,int(random(3))), array3.at(0,int(random(3))))