-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a33f0bd
commit 801d670
Showing
3 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Destructor Methods | ||
|
||
Destructor methods are methods that are called automatically when created instances of structures are destroyed. It is usually used when there is a memory space that needs to be freed, or in similar circumstances. | ||
|
||
Destructor methods are called automatically even on immutable instances. There is no harm in mutable operation since it is out of scope. But the need for mutability can arise when you want to call the method manually. | ||
|
||
## The Dispose Trait | ||
|
||
Jule has a built-in `Dispose` trait. To obtain a destructor method, it is necessary to implement the `Dispose` trait. Structures that implement this trait have a `dispose` method. This method is the destructor method and is called automatically when the build instances are destroyed. | ||
|
||
For example: | ||
```jule | ||
impl Dispose for MyStruct { | ||
pub fn dispose(mut self) { | ||
// ... | ||
} | ||
} | ||
``` |
File renamed without changes.