A block is the same thing as a method, but it does not belong to an object. Blocks are called closures in other programming languages. There are some important points about Blocks in crystal: Block can accept arguments and returns a value. ...
The initialize method is useful when we want to initialize some class variables at the time of object creation. The initialize method is part of the object-creation process in Crystal and it allows us to set the initial values for an object. Below ar...
The word iterate means doing one thing multiple times and that is what iterators do. Sometimes iterators are termed as the custom loops. “Iterators” is the object-oriented concept in crystal. In more simple words, iterators are the methods w...
In crystal lang, static members are known as class variables. These variables are shared among all instances of a class and are declared using the @@ symbol. Class variables retain their value across different instances of the class and can be access...
In CrystalLang, a lambda is a type of anonymous function or a block of code that can be assigned to a variable or used inline. It encapsulates control flow, parameters, and local variables into a single package. lambda_variable = ->(param) { p...
In Crystal, one does not have anything like the variable types as there is in other programming languages. Every variable is an “object” which can be individually modified. One can easily add methods and functions on every object. So here, the Object...
Encapsulation is defined as the wrapping up of data under a single unit. It is the mechanism that binds together code and the data it manipulates. In a different way, encapsulation is a protective shield that prevents the data from being accessed by ...
EDIT: It's now 1.5 years since I wrote this post, and I forgot to update it: most of the problems discussed below are gone! The application is compiling and running smoothly in ---release mode. The customer is still happy, everything is working perfe...