Toggle Comment
Whenever I want to test an alternative implementation of some code I sometimes would like to preserve the old code and quickly toggle between the new and old implementation for comparison. I came up with a slick way to toggle between code using comments.
Example:
//*
if (name->Length() > 0) //Old way
{
DoStuff(name);
}
/*/
if (name != NULL && name->Length() > 0) //New way
{
DoStuff(name);
}
//*/
To toggle between the two implementations you simply remove the first / from the first comment.
Written by Keith Bickley
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Comments
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#