Post History
Remove print's parentheses when it's a single string print strangely works without parentheses, however, it only applies to single strings. In other words, it can't do the same for other variables...
Answer
#2: Post edited
- # Remove `print`'s parentheses when it's a single string
- `print` strangely works without parentheses, however, it only applies to single strings. In other words, it can't do the same for other variables or string concatenation inside the function.
- For example:
- ```lua
- print("Hello, World!")
- ```
- Works, but can be shortened to:
- ```lua
- print"Hello, World!"
- ```
- Saving 2 bytes for all cases.
- [Try it online!](https://tio.run/##yylN/P@/oCgzr0TJIzUnJ19HITy/KCdFUen/fwA "Lua – Try It Online")
- These don't work:
- ```lua
- i=10
- print i
- ```
- [Try it online!](https://tio.run/##yylN/P8/09bQgKugKDOvRCHz/38A "Lua – Try It Online")
- ```lua
- name="Mark"
- print"Hello, "..name.."."
- ```
[Try it online!](https://tio.run/##yylN/P8/LzE31VbJN7EoW4mroCgzr0TJIzUnJ19HQUlPDySnp6ekp/T/PwA "Lua – Try It Online")
- # Remove `print`'s parentheses when it's a single string
- `print` strangely works without parentheses, however, it only applies to single strings. In other words, it can't do the same for other variables or string concatenation inside the function.
- For example:
- ```lua
- print("Hello, World!")
- ```
- Works, but can be shortened to:
- ```lua
- print"Hello, World!"
- ```
- Saving 2 bytes for all cases.
- [Try it online!](https://tio.run/##yylN/P@/oCgzr0TJIzUnJ19HITy/KCdFUen/fwA "Lua – Try It Online")
- These don't work:
- ```lua
- i=10
- print i
- ```
- [Try it online!](https://tio.run/##yylN/P8/09bQgKugKDOvRCHz/38A "Lua – Try It Online")
- ```lua
- name="Mark"
- print"Hello, "..name.."."
- ```
- [Try it online!](https://tio.run/##yylN/P8/LzE31VbJN7EoW4mroCgzr0TJIzUnJ19HQUlPDySnp6ekp/T/PwA "Lua – Try It Online")
- You'll need to encase them in parentheses if so.
#1: Initial revision
# Remove `print`'s parentheses when it's a single string `print` strangely works without parentheses, however, it only applies to single strings. In other words, it can't do the same for other variables or string concatenation inside the function. For example: ```lua print("Hello, World!") ``` Works, but can be shortened to: ```lua print"Hello, World!" ``` Saving 2 bytes for all cases. [Try it online!](https://tio.run/##yylN/P@/oCgzr0TJIzUnJ19HITy/KCdFUen/fwA "Lua – Try It Online") These don't work: ```lua i=10 print i ``` [Try it online!](https://tio.run/##yylN/P8/09bQgKugKDOvRCHz/38A "Lua – Try It Online") ```lua name="Mark" print"Hello, "..name.."." ``` [Try it online!](https://tio.run/##yylN/P8/LzE31VbJN7EoW4mroCgzr0TJIzUnJ19HQUlPDySnp6ekp/T/PwA "Lua – Try It Online")