User Tools

Site Tools


expression

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
expression [2014/07/23 12:42]
l
expression [2017/10/10 00:39] (current)
Line 1: Line 1:
 +<- [[display|Displaying A Passage Within Another]] --------- [[function|About Functions]]->​
 +
 ===== About Expressions ===== ===== About Expressions =====
  
Line 59: Line 61:
  
 Usually, though, there isn't much call for this - numbers are generally as useful as strings.) Usually, though, there isn't much call for this - numbers are generally as useful as strings.)
 +
 +==== Printing Lists ====
 +
 +If you have a list, you can print the contents separated by a comma like so:
 +
 +    <<set $myarray = ["​this",​ "​that"​]>>​
 +    <<​print $myarray.join(",​ "​)>>​
 +
 +This will print the following:
 +
 +     ​this,​that
 +
 +
 +If you have specific questions about using lists in Twine, the [[frequently_asked_questions#​how_do_i_get_things_in_and_out_of_a_list_variable|FAQ]] may help.
 +
  
 ==== Functions ==== ==== Functions ====
Line 130: Line 147:
 | "Some text", "​2",​ "​true",​ 'More text', '​4',​ '​true'​ | **Strings**:​ snippets of text characters that can be [[<<​print>>​]]ed,​ joined up, or compared. Note that "​2"​ and "​true"​ resemble other types but are nonetheless strings. | | "Some text", "​2",​ "​true",​ 'More text', '​4',​ '​true'​ | **Strings**:​ snippets of text characters that can be [[<<​print>>​]]ed,​ joined up, or compared. Note that "​2"​ and "​true"​ resemble other types but are nonetheless strings. |
 | 0, 2, 5, -11, 45.25, Infinity | **Numbers** that can be used in arithmetic calculations. ''​Infinity''​ isn't really a number, but has the special property that it's always ''>''​ and ''>​=''​ every actual number, so you can use it in that case. (The same applies to ''​-Infinity''​ and ''<''/''<​=''​) | | 0, 2, 5, -11, 45.25, Infinity | **Numbers** that can be used in arithmetic calculations. ''​Infinity''​ isn't really a number, but has the special property that it's always ''>''​ and ''>​=''​ every actual number, so you can use it in that case. (The same applies to ''​-Infinity''​ and ''<''/''<​=''​) |
-| true, false | **Logical values**, created using the logical operators, and commonly used with to the [[<<​if>>​]] macro. True and false are the only values of this type. |+| true, false | **Logical values**, created using the logical operators, and commonly used with to the [[<<​if>>​]] macro. True and false are the only values of this type. 
 + 
 +<- [[display|Displaying A Passage Within Another]] --------- [[function|About Functions]]->​
expression.1406119321.txt.gz · Last modified: 2017/10/10 00:37 (external edit)