string.reverse

Return the given str with the character order reversed.

ExamplePrint the reverse of user input
Read a line from the user, then print the same input reversed.
Code
<nowiki>
print(string.reverse(read()))
    </nowiki>
Output Depends on what the user wrote. For instance, if they were to enter Hello World, the output would be dlroW olleH.

string.reverse
Function
Syntax
string.reverse(
  • str : string
)
Colon notation: str:reverse()

Returns string
API string
Source Lua (source)
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.