January 2019
Intermediate to advanced
246 pages
5h 23m
English
While you can write working code line by line without structuring it, you won’t usually get very far before you want to be able to reuse code and store logic in more sophisticated ways. Methods (sometimes called functions) let you group code into chunks, and you give them names so you can call them. In this chapter, you’ll see Crystal’s approach to methods. It’s very Ruby-like, though Crystal’s use of types creates some differences on the way to performant and readable code. If you feel the need, review Using Methods to get an introduction to methods.
Because everything is an object in Crystal, there are methods on everything, even simple values such as Int32 and Char. Operators such as / or ...
Read now
Unlock full access