Chapter 2
Crystal Foundations

In this chapter, you’ll work through a Crystal tutorial. You’ll learn to create and manipulate simple kinds of data and data structures. You’ll write code that decides what to do based on the data it receives, and you’ll learn how to structure that code into methods, classes, modules, and fibers. This chapter will give you the foundation you need to do simple things in Crystal, and later chapters will provide much more detail about larger possibilities.

If you’re a Rubyist, Crystal should make you feel right at home. You can probably skim through, focusing especially on differences from Ruby. In fact, in Organizing Code in Classes and Modules, you’ll port some Ruby code step-by-step to Crystal. You’ll soon realize that with Crystal, it’s all about the messages you get at compile-time, while with Ruby, everything happens at runtime.

If you’re not a Ruby developer, the syntax may seem strange at first, but in time, you’ll see how concise and intuitive it is.

Then, in Part II, we’ll take a closer look at some important details and gain more insight into why Crystal works the way it does.

Start up your Crystal Playground[23] environment to follow along.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.110.155