- Phoenix Web Development
- Brandon Richey
- 142字
- 2021-08-27 18:28:21
Variables in Elixir
Like most other programming languages, Elixir has a concept of variables. Variables are, simply put, just a place to store values or data. Variables in Elixir do not require any sort of type definition or declaration that they're variables, as you might see in languages such as JavaScript. We can declare a new variable as simply as follows:
iex(1)> greeting = "Hello There"
"Hello There"
In IEx, the output of any statement entered is always the next line in the shell.
Variables point to memory locations, so when you use them in your code, the values stored in those memory locations are automatically pulled out for you, as shown in the following example:
iex(2)> greeting
"Hello There"
While variables can be reassigned in Elixir, the actual values are immutable! This brings us to our first gotcha in Elixir: immutability.
推薦閱讀
- 網(wǎng)絡(luò)協(xié)議工程
- Modern JavaScript Web Development Cookbook
- 物聯(lián)網(wǎng)智慧安監(jiān)技術(shù)
- 5G承載網(wǎng)網(wǎng)絡(luò)規(guī)劃與組網(wǎng)設(shè)計(jì)
- 物聯(lián)網(wǎng)安全與深度學(xué)習(xí)技術(shù)
- Web Application Development with R Using Shiny
- IPv6網(wǎng)絡(luò)切片:使能千行百業(yè)新體驗(yàn)
- Working with Legacy Systems
- VMware NSX網(wǎng)絡(luò)虛擬化入門
- 物聯(lián)網(wǎng)與智能家居
- INSTANT LinkedIn Customization How-to
- Professional Scala
- 數(shù)字王國里的虛擬人:技術(shù)、商業(yè)與法律解讀
- 物聯(lián)網(wǎng)M2M開發(fā)技術(shù):基于無線CPU-Q26XX
- 物聯(lián)網(wǎng)與智慧廣電