This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

%= operator?

 
Randy Trover
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I know the mod operator is %, but what does the %= do? Thanks for any help.
Cheers
Randy
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a %= b is the same as
a = a % b;
where you stuff the result back into the a value that you started with.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Works just like '+=', '-=', and all the other math shortcut operators...



Both have the same effect... they assign the modulus of someNum and 5 to someNum...

HTH,
-Nate

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic