You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3. Test it locally, you need to install the gems `jekyll` and `redcarpet`:
30
32
31
-
```shell
32
-
$ gem install jekyll redcarpet
33
-
$ jekyll serve # check localhost:4000
34
-
```
33
+
```bash
34
+
$ gem install jekyll redcarpet
35
+
$ jekyll serve # check localhost:4000
36
+
```
35
37
36
-
4. Send a pull-request for your changes
38
+
4. Push to your forked repository.
39
+
40
+
5. Submit a pull-request for your changes.
37
41
38
42
`jekyll` requires a javascript processor to be available too. Many OS provide such functionality but others do not. If you have an error related to ExecJS, you can work around it by either running `gem install therubyracer` or by ensuring node.js is available in your path.
Copy file name to clipboardExpand all lines: _posts/2014-04-21-elixir-v0-13-0-released.markdown
+1-1
Original file line number
Diff line number
Diff line change
@@ -241,7 +241,7 @@ The last big change we want to discuss in this release are the improvements done
241
241
242
242
In previous releases, Mix was used to download and compile dependencies per environment. That meant the usual workflow was less than ideal: every time a dependency was updated, developers had to explicitly fetch and compile the dependencies for each environment. The workflow would be something like:
Copy file name to clipboardExpand all lines: crash-course.markdown
+31-48
Original file line number
Diff line number
Diff line change
@@ -8,20 +8,10 @@ layout: default
8
8
9
9
This is a quick introduction to the Elixir syntax for Erlang developers and vice-versa. It is the absolute minimum amount of knowledge you need in order to understand Elixir/Erlang code, support interoperability, read the docs, sample code, etc.
10
10
11
-
This page is divided into sections:
11
+
<divclass="toc"></div>
12
12
13
-
1.[Running Code](#running_code)
14
-
2.[Notable Differences](#notable_differences)
15
-
3.[Data Types](#data_types)
16
-
4.[Modules](#modules)
17
-
5.[Function Syntax](#function_syntax)
18
-
6.[Control Flow](#control_flow)
19
-
7.[Adding Elixir to existing Erlang programs](#interop)
20
-
8.[Further reading](#further_reading)
21
13
22
-
<divid="running_code"></div>
23
-
24
-
## 1 Running Code
14
+
## Running code
25
15
26
16
### Erlang
27
17
@@ -82,26 +72,25 @@ defmodule MyModule do
82
72
end
83
73
```
84
74
85
-
<divid="notable_differences"></div>
86
75
87
-
## 2 Notable Differences
76
+
## Notable differences
88
77
89
78
This section goes over some of the syntactic differences between the two languages.
| and | NOT AVAILABLE | Logical 'and', evaluates both arguments |
87
+
| andalso | and | Logical 'and', short-circuits |
88
+
| or | NOT AVAILABLE | Logical 'or', evaluates both arguments |
89
+
| orelse | or | Logical 'or', short-circuits |
90
+
| =:= | === | A match operator |
91
+
| =/= | !== | A negative match |
92
+
| /= | != | Not equals |
93
+
| =< | <= | Less than or equals |
105
94
106
95
107
96
### Delimiters
@@ -122,7 +111,7 @@ x = 2; y = 3
122
111
x + y
123
112
```
124
113
125
-
### Variable Names
114
+
### Variable names
126
115
127
116
Variables in Erlang can only be assigned once. The Erlang shell provides a special command `f` that allows you to erase the binding of a variable or all variables at once.
128
117
@@ -161,14 +150,14 @@ iex> ^a = 3
161
150
** (MatchError) no match of right hand side value: 3
162
151
```
163
152
164
-
### Calling Functions
153
+
### Calling functions
165
154
166
155
Elixir allows you to omit parentheses in function calls, Erlang does not.
167
156
168
-
| Erlang | Elixir |
169
-
--------------------------------------
170
-
| some_function(). | some_function |
171
-
| sum(A, B) | sum a, b |
157
+
| Erlang | Elixir |
158
+
|-------------------|----------------|
159
+
| some_function(). | some_function |
160
+
| sum(A, B) | sum a, b |
172
161
173
162
Invoking a function from a module uses different syntax. In Erlang, you would write
174
163
@@ -190,9 +179,8 @@ Kernel.self
190
179
191
180
All of the Erlang built-ins reside in the `:erlang` module.
192
181
193
-
<divid="data_types"></div>
194
182
195
-
## 3 Data Types
183
+
## Data types
196
184
197
185
Erlang and Elixir have the same data types for the most part, but there are a number of differences.
[This chapter][3] from the Erlang book provides a detailed description of pattern matching and function syntax in Erlang. Here, I'm briefly covering the main points and provide sample code both in Erlang and Elixir.
Pattern matching in Elixir is based on Erlang's implementation and in general is very similar:
466
452
@@ -574,7 +560,7 @@ mul_by 4, 3 #=> 12
574
560
mul_by 4#=> 8
575
561
```
576
562
577
-
### Anonymous Functions
563
+
### Anonymous functions
578
564
579
565
Anonymous functions are defined in the following way:
580
566
@@ -637,7 +623,7 @@ f.({:a, :b})
637
623
#=> "All your {:a,:b} are belong to us"
638
624
```
639
625
640
-
### First-Class Functions
626
+
### First-class functions
641
627
642
628
Anonymous functions are first-class values, so they can be passed as arguments to other functions and also can serve as a return value. There is a special syntax to allow named functions be treated in the same manner.
The constructs `if` and `case` are actually expressions in both Erlang and Elixir, but may be used for control flow as in imperative languages.
700
685
@@ -791,7 +776,7 @@ else
791
776
end
792
777
```
793
778
794
-
### Sending and Receiving Messages
779
+
### Sending and receiving messages
795
780
796
781
The syntax for sending and receiving differs only slightly between Erlang and Elixir.
797
782
@@ -825,9 +810,8 @@ after
825
810
end
826
811
```
827
812
828
-
<divid="interop"></div>
829
813
830
-
## 7 Adding Elixir to existing Erlang programs
814
+
## Adding Elixir to existing Erlang programs
831
815
832
816
Elixir compiles into BEAM byte code (via Erlang Abstract Format). This means that Elixir code can be called from Erlang and vice versa, without the need to write any bindings. All Elixir modules start with the `Elixir.` prefix followed by the regular Elixir name. For example, here is how to use the utf-8 aware `String` downcase from Elixir in Erlang:
833
817
@@ -859,9 +843,8 @@ This should be enough to invoke Elixir functions straight from your Erlang code.
859
843
860
844
If you are not using rebar, the easiest approach to use Elixir in your existing Erlang software is to install Elixir using one of the different ways specified in the [Getting Started guide](/getting-started/introduction.html) and add the `lib` directory in your checkout to `ERL_LIBS`.
861
845
862
-
<divid="further_reading"></div>
863
846
864
-
## 8 Further Reading
847
+
## Further reading
865
848
866
849
Erlang's official documentation site has a nice [collection][4] of programming examples. It can be a good exercise to translate them into Elixir. [Erlang cookbook][5] offers even more useful code examples.
Copy file name to clipboardExpand all lines: getting-started/mix-otp/agent.markdown
+3-1
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,9 @@ We will explore all of these abstractions in this guide. Keep in mind that they
32
32
33
33
[Agents](/docs/stable/elixir/Agent.html) are simple wrappers around state. If all you want from a process is to keep state, agents are a great fit. Let's start an `iex` session inside the project with:
0 commit comments