ClassSet ()

symbolpart valueorClassSet[symbolpart,value]
sets part in the symbol symbol representing a class instance to the evaluated value.

{l1,l2,}{r1,r2,}
evaluates the ri and assigns the results to be the values of the corresponding li.

DetailsDetails

  • ClassSet is a limited counterpart to Set designed specifically for symbols representing class instances.
  • ClassSet performs a similar role as Affix and AffixTo.
  • The infix operator can be entered as Esc=<Esc.
  • ClassSet is overloaded so that Part works with class instances as if they were Association objects.
  • Part 0 of a symbol refers to its head, which is the same as its class symbol. symbol0class changes the class of the instance represented by symbol to class.
  • symbol"key"value associates value to the element indicated by "key".
  • New assignments with identical left-hand sides overwrite old ones.
  • You can obtain the underlying Association object stored in symbol using Normal[symbol].
  • ClassSet has attribute HoldFirst.
  • part is evaluated.
  • lhsrhs evaluates to rhs even if for some reason the assignment specified cannot be performed.
  • ClassSet is a low-level function that does not strictly enforce the result to satisfy any invariants, though it will print a warning when ValidQ does not return True when applied to the result.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

In[1]:=
Click for copyable input

Convert class from object.

In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=