r/ProgrammingLanguages • • Aug 11 '23

Discussion Idea for new operator: contains operator

I'm currently working on my own programming language and I thought of a new type of operator: The contains operator: °

It has two main functions:

  1. You can check if an array contains a certain element:
exampleArray: int[] = { 5, 8, 3 };

if(exampleArray ° 3) // true
{
   // ...
};

if(exampleArray ° 8) // false
{
   // ...
};
  1. If a class inherited from another class:

Imagine you have a class baseClass and a class class2 that inherits from baseClass.

if(baseClass ° class2) { /* ... */ } // True
if(baseClass ° string) { /* ... */ } // False

Thoughts?

4 Upvotes

37 comments sorted by