Tip/trick to (de)activate or comment out code

This is not a question but I'm sharing a method that I've been using to activate and de-activate code by adding/removing just one single forward slash.

I'm probably not the first to use this method but I haven't come across it anywhere else.

It works like this:

  /*
  Inactive code
  //*/

  //*
  Active code
  //*/

The difference is a one single forward slash.
Works in Javascript too.

2 Likes

C pre-processor directives

#if 0
#else
#endif
2 Likes
  if (0) {
  }
4 Likes

That's funny. I didn't bother to post my favorite

  if (1) {
  }

Does that mean I'm the optimist? :expressionless:

a7

2 Likes

No thanks, I'll stay with the method that is easy to see.

1 Like

For you and for everyone... convention is there for a reason, and is never a tip or a trick.

1 Like

Well, thanks for this, that's way easier :slight_smile:
Same approach works in micropython as well

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.