Group Abstract Group Abstract

Message Boards Message Boards

0
|
73 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Adding Information to custom objects

POSTED BY: Andreas Hafver
2 Replies

I believe this is how it works.

Information`AddRegistry[MyObject, getMyObjectInformation];
getMyObjectInformation[MyObject[ass_?MyObjectQ]] := <|
  (* this first key is mandatory *)
  "ObjectType" -> "MyObject",
  (* next just include the whole inner association *)
  ass, 
  (* now define any computed properties using RuleDelayed *)
  "Length" :> Length[ass["List"]]
|>

And now it works as expected:

enter image description here

POSTED BY: Jason Biggs

Great, thank you very much!

POSTED BY: Andreas Hafver
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard