Understanding Elixir Modules: Namespaces or Classes?

201
clicks
Understanding Elixir Modules: Namespaces or Classes?

Source: reddit.com

Type: Discussion

The content presents a query by the author, magingax, who is trying to understand the nature of modules in Elixir. They have likened modules to namespaces, as it is common to consider them in many programming languages. However, the author's confusion arises from the ability to use 'defstruct' within a module to create instances, which is a characteristic often associated with classes in object-oriented programming (OOP). This raises the question of whether Elixir modules should be thought of as classes, given that they can encapsulate both state (through 'defstruct') and behavior (with functions).

© HashMerge 2024