mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2026-11-28 18:12:39 +08:00
* refactor: clean to roadmap content * refactor: move shared helpers into scripts/lib
10 lines
983 B
Markdown
10 lines
983 B
Markdown
# define_method
|
||
|
||
`define_method` is a method used to dynamically create new methods within a class or module. Instead of explicitly writing out the method definition with the `def` keyword, `define_method` allows you to generate methods at runtime, often based on data or logic that isn't known until the program is running. This provides a powerful way to reduce code duplication and create more flexible and adaptable code.
|
||
|
||
Visit the following resources to learn more:
|
||
|
||
- [@article@Dynamic method definition with ruby’s .define_method](https://medium.com/@camfeg/dynamic-method-definition-with-rubys-define-method-b3ffbbee8197)
|
||
- [@article@Explain Ruby's define_method like I'm five](https://dev.to/tiffanywismer/explain-rubys-definemethod-like-im-five-2807)
|
||
- [@video@define_method - Metaprogramming in Ruby](https://www.youtube.com/watch?v=I0itVuoprAY)
|
||
- [@video@Ruby Tutorial | Metaprogramming in Ruby - Dynamic Method Definition](https://www.youtube.com/watch?v=bg2KvfwxDnM) |