Feature [ASH] "in" operator (and expanding "contains")

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
I wrote quick support for an "in" operator, as well as some improvement to "contains". Thus this has two new features:

  • "in" as the inverse of "contains" (i.e haystack contains needle is equivalent to needle in haystack)
  • "contains" can now be applied to two strings for what is essentially a "contains_text" check (this is also the case for "in")

This is nothing that the language is crying out for necessarily but certainly something that will make scripts easier to read in many circumstances. Particularly in the case of "in", it is often more logical to see the needle before the haystack. Much like the backtick template strings I implemented last year, it is a "quick win" to make ASH slightly easier/nicer/neater for its users!

There should be no clashes with the existing use of the reserved word "in" in the foreach structure but rather than push it and be proved wrong, I thought I would post a patch for inspection in case I overlooked a case.

Gausie

EDIT: Ignore the whitespace issues, I'll fix them before committing.
 

Attachments

  • contains_and_in.patch
    3.1 KB · Views: 8
Top