C.3. When memory locations stay the same
Custom type variants that don’t hold data—for example, the values True, False, and Nothing—always have the same memory location. They work the same way with lazy as strings and numbers do. (In contrast, values created with Just might not have the same memory locations, because Just holds data.)
Other values keep the same memory location when they are passed around. Table C.2 shows some ways to get a value with the same memory location as another value.
Table C.2. Ways to get a value with the same memory location as another value
Operation yielding same memory location |
Examples |
---|---|
Assigning it to another constant | sameMemory = oldValue |
Reading it from a record field | sameMemory = record.oldValue ... |
Get Elm in Action now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.