Problem of the Day
A new programming or logic puzzle every Mon-Fri

Programming Trick

Today's problem is an easy one. The goal is to help everyone learn more. To do so today's problem is to share a programming trick for the language(s) of your choice. Here's an example:

In JavaScript you can coerce just about any value to an integer by attempting a bit shift.

undefined >> 0 = 0
NaN >> 0 = 0
false >> 0 = 0
true >> 0 = 1
"g" >> 0 = 0
[] >> 0 = 0
1 >> 0 = 1

Permalink: http://problemotd.com/problem/programming-trick/

Comments:

  • There are currently no comments. You can be first!

Content curated by @MaxBurstein