Search code examples
ozmozart

What is the difference between "@attr = ..." and "attr := ..." on class attributes?


The text book for my class warns not to mix up @attr = ... and attr := ... when working with class attributes. It does not, however, explain what the difference is. I know that when working with cells, MyCell := ... changes the contents of the cell, but I have never seen @something = ....


Solution

  • C={NewCell 4}
    @C=3
    {Browse @C}
    

    The code above outputs nothing, because @C=3 is the same as

    {Cell.access C $}=3
    

    and as the function {Cell.access C $} return 4, it is the same as

    4=3
    

    To assign a new value to a Cell, you must use `:='