官术网_书友最值得收藏!

Elixir's data types

We will now describe Elixir's data types, which extend upon Erlang's data types. Elixir is a dynamic programming language. Consequently, you don't declare the type of each variable—it depends on the value it holds at each moment.

To improve the learning experience, we'll be providing some examples along the way. For now, we'll just use Elixir's REPL, IEx (short for Interactive Elixir). To start an IEx session, you must have Elixir installed on your machine. Elixir has an official page with instructions on how to do this if you don't have it installed,  whether using package managers, the precompiled version, or compiling from the source yourself:

http://elixir-lang.github.io/install.html 

We will not dive into the memory usage of each type in Elixir. If you're curious about this, the official Erlang documentation contains detailed information:  http://erlang.org/doc/efficiency_guide/advanced.html.

Provided that you have Elixir already installed on your machine, type iex on your terminal to start a new IEx session. With this, you can run the examples present in this chapter in your machine. Note that your default iex  prompt contains a number in between parenthesis, which represents the number of expressions you've entered in the current session, such as iex>(1). To declutter the output, in our examples, we've removed this number.

We'll be exploring IEx in greater detail toward the end of this chapter, in the Tooling and ecosystems section. Throughout the following subsections, we'll be mentioning some built-in modules in Elixir. We'll explore what modules are in the Functions and modules section—for now, it's enough to know that a module is a collection of functions.

Whenever you're done with your IEx session, you can either press Ctrl C twice or Ctrl \. This will kill the operating system process that's running the Erlang runtime (along with all background jobs). Alternatively, you can stop the system in a more polite way by entering System.halt in the shell.
主站蜘蛛池模板: 类乌齐县| 新安县| 高唐县| 曲阜市| 鄂州市| 铅山县| 昌图县| 正蓝旗| 普兰店市| 禄劝| 江津市| 闸北区| 丰台区| 昭通市| 蚌埠市| 琼中| 万州区| 沛县| 观塘区| 望城县| 徐水县| 莱西市| 德阳市| 泽州县| 长顺县| 抚顺市| 清远市| 霸州市| 永靖县| 沁源县| 庆安县| 徐闻县| 弥勒县| 天峨县| 平果县| 南澳县| 渝中区| 松桃| 冕宁县| 日喀则市| 盐源县|