Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

2. Mutations … it's a bad thing!

Sumit Rawal answered on August 28, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers


2. Mutations … it's a bad thing!

0

If you have worked on large enterprise codebase with thousands of lines of code, I'm pretty sure that you've had more than just a few cups of coffee :) to get you through solving some particular bug in the system.

Flipping the coin over. What if you were solving the same bug, but your thousands of lines of code had no mutations to your variables! As we will see in upcoming tutorials from Chapter 2, Scala highly encourages immutability as a first class citizen in the language.

Say you had defined a variable called cupOfCoffeeEnergy which was initialized from the energy function in Step 1. Then, regardless of where you are in your thousands of lines of code, you know that the value of your cupOfCoffeeEnergy will be exactly the same!

Therefore, if your bug was a wrong value being represented for the variable cupOfCoffeeEnergy, then the solution would be to simply step through the energy function from Step 1 regardless of your thousands of lines of code!

Popularity 1/10 Helpfulness 1/10 Language whatever
Source: Grepper
Tags: whatever
Link to this answer
Share Copy Link
Contributed on Aug 28 2023
Sumit Rawal
0 Answers  Avg Quality 2/10


X

Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.