Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualSarmon

Posted 21 July 2012 - 03:32 AM


if (username == "Tiffany" || "tiffany" || "Tiffany McClure" || "tiffany McClure" || "Tiffany Mcclure" || "tiffany mcclue")



Am I the only one thinking that looks pretty elegant? Is there any language that implements this way of checking the same variable for different boolean cases?

Regular expressions can match a specified pattern, every language will have at least one implementation of a regex language.

EDIT: Although that's not exactly what you're asking, the effect is to want to test your variable against a range, which for strings is equivalent to a pattern.

#1Sarmon

Posted 21 July 2012 - 03:30 AM


if (username == "Tiffany" || "tiffany" || "Tiffany McClure" || "tiffany McClure" || "Tiffany Mcclure" || "tiffany mcclue")



Am I the only one thinking that looks pretty elegant? Is there any language that implements this way of checking the same variable for different boolean cases?

Regular expressions can match a specified pattern, every language will have at least one implementation of a regex language.

PARTNERS