Skip to main content
modified first snippet so it saves bytes. removed linebreaks to visualize shorter/longer code
Source Link
Titus
  • 14.8k
  • 1
  • 24
  • 41

Maybe somewhat obvious but...

Make use of operator return values

Keep in mind that the assignment operator returns a value!

For example, if you want to add y to x and then check if x is greater than something, you can do

if((x+=y)>2525<x+=y)

instead of

x+=y
ifx+=y;if(x>25)

Or maybe you want to find the length of a string after trimming it:

strlen(s=trim(s))

Rather than

s=trim(s)
strlen;strlen(s)

Maybe somewhat obvious but...

Make use of operator return values

Keep in mind that the assignment operator returns a value!

For example, if you want to add y to x and then check if x is greater than something, you can do

if((x+=y)>25)

instead of

x+=y
if(x>25)

Or maybe you want to find the length of a string after trimming it:

strlen(s=trim(s))

Rather than

s=trim(s)
strlen(s)

Maybe somewhat obvious but...

Make use of operator return values

Keep in mind that the assignment operator returns a value!

For example, if you want to add y to x and then check if x is greater than something, you can do

if(25<x+=y)

instead of

x+=y;if(x>25)

Or maybe you want to find the length of a string after trimming it:

strlen(s=trim(s))

Rather than

s=trim(s);strlen(s)
Source Link
orp
  • 261
  • 2
  • 5

Maybe somewhat obvious but...

Make use of operator return values

Keep in mind that the assignment operator returns a value!

For example, if you want to add y to x and then check if x is greater than something, you can do

if((x+=y)>25)

instead of

x+=y
if(x>25)

Or maybe you want to find the length of a string after trimming it:

strlen(s=trim(s))

Rather than

s=trim(s)
strlen(s)