Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
core.factory
- Object
factory
(alias mod)(stringclassname
); - Create instance of class specified by the module symbol and a string representing the name of the class. The class must either have no constructors or have a default constructor.Parameters:
mod symbol representing the module that the class is in string classname
string representing the name of the class Returns:null if failedExample
module foo.bar; class C { this() { x = 10; } int x; } void main() { auto c = cast(C)factory!(foo.bar)("C"); assert(c !is null && c.x == 10); }
Copyright © 1999-2024 by the D Language Foundation | Page generated by
Ddoc on Wed Dec 18 08:52:03 2024