Skip to content

Commit 7f23262

Browse files
committed
update
1 parent c5ceb8d commit 7f23262

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,69 @@ true
300300
>> ==(list(1, 2), list(1, 2))
301301
false
302302
```
303+
304+
##Variables
305+
306+
In RoyalScript, variables are assigned to literals using the *=()* function. You can only assign one variable in each call to the function. You can use any variable name that starts with a letter, *$*, or *_*, and has the same characters or digits after that. For example:
307+
308+
```
309+
>> =(r, 3)
310+
undefined
311+
>> do(r)
312+
3
313+
>> =(r,e,3)
314+
Argument Error: Got improper arguments but expected 2.
315+
>> =(r,2)
316+
undefined
317+
>> do(r)
318+
2
319+
>> =($$$$, 1000000)
320+
undefined
321+
>> =(%%%, `this is a bad variable name`)
322+
SyntaxError: Unexpected token %
323+
```
324+
325+
You can however reassign an existing variable. If you want to declare a variable with no actual value initially, you can assign it to *null* or *undefined*.
326+
327+
##String Functions
328+
329+
Strings in RoyalScript are types that represent a series of characters or bytes for textual data. They are immutable, but have a series of functions they can be used with for meaningful computation.
330+
331+
**Warning**: Strings in RoyalScript cannot contain newlines, otherwise an error will be raised.
332+
333+
###&(arg1, arg2)
334+
335+
The *&()* function takes two string or list operands (also works on lists) and concats them, returning or evaluating to a new string or list.
336+
337+
```
338+
>> &(`h`, `e`)
339+
"he"
340+
>> &(`1`, `2`, `3`)
341+
Argument Error: Got improper arguments but expected 2.
342+
>> &(`12`)
343+
Argument Error: Got improper arguments but expected 2.
344+
```
345+
346+
###str(arg1)
347+
348+
The *str()* function converts a number or an expression that evaluates to a number to a string.
349+
350+
```
351+
>> str(4)
352+
"4"
353+
>> str(+(1, 2, 3, 4))
354+
"10"
355+
>> str(+(1, 2, 3, 4), 3)
356+
Argument Error: Got improper arguments but expected 1.
357+
```
358+
359+
###num(arg1)
360+
361+
The *num()* function takes one string argument and converts it to a number.
362+
363+
```
364+
>> num(`4`)
365+
4
366+
>> num(str(4))
367+
4
368+
```

0 commit comments

Comments
 (0)