Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi

 

In Chapter 1 it discusses variable and constants. Why would you not simply assign a value to a variable and then not change it as opposed to defining a constant? or is there other benefits by defining constants?

 

 

 

Link to comment
Share on other sites

It's a matter of protection: you never have to worry about a constant's value changing. Whereas you might think you've written code that wouldn't assign a value to a variable and then make a mistake. Constants also have global scope. 

Link to comment
Share on other sites

 Share

×
×
  • Create New...