Ruby - Area of Ployline


ComputerMaster86
 Share

Recommended Posts

1 hour ago, solver said:

Joe: Is the string conversion really needed, or just the proper way to do it -- like explicitly assigning a value to result.

Eric,

 

I do that so the it's easy to add (concatenate) the result.

example:

  • result = area.round(2).to_s + " sq.ft."
  • result = "Area = " + result

or, if you want to perform some other calculations:

  • x = area.round(2)
  • result = "Area = " + x.to_s + " sq.ft."

There are other ways of coding to get the same result.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share