Logo

Programming-Idioms

History of Idiom 97 > diff from v22 to v23

Edit summary for version 23 by Marolex:
[Lua] My explanation was incorrect

Version 22

2017-03-02, 05:46:01

Version 23

2017-03-02, 05:46:56

Idiom #97 Check string suffix

Set boolean b to true if string s ends with suffix suffix, false otherwise.

Illustration

Idiom #97 Check string suffix

Set boolean b to true if string s ends with suffix suffix, false otherwise.

Illustration
Code
b = s:sub(-5) == suffix
Code
b = s:sub(-5) == suffix
Comments bubble
-5 is equal to the length of your non static suffix.
Comments bubble
-5 is equal to the length of your static suffix.