-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object.createFrom() #539
Object.createFrom() #539
Conversation
```cs | ||
class Test {} | ||
|
||
Object.getClassRef("Test").unwrap(); // <Cls Test> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an easy way to get the name of the class from an object? I know we have a getAttributes method but I don't believe it includes the name of the class. That might be a nice addition so this can be even more dynamic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you say class name, do you mean an actual reference to the class or do you mean the string representation of the class name?
For example, if you already have the object you can get the class reference via: https://dictu-lang.com/docs/classes/#_class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string representation of the class name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah there's currently no way to turn a class reference into a string'd name. We could add a _name
attribute similar to _class
to classes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be cool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be added as part of #543
Now it would be:
class Test {}
print(Test._name);
print(Test()._class._name);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool!
Well detailed description of the change :
This PR adds a new module
Object
that allows us to retrieve class references via strings or objects to be created via strings rather than always having a reference to the class.Type of change:
Housekeeping
Tests have been updated to reflect the changes done within this PR (if applicable).
Documentation has been updated to reflect the changes done within this PR (if applicable).