Skip to content

Commit c9dfa51

Browse files
committed
replaced highlight ruby with highlight elixir
1 parent 3887b97 commit c9dfa51

File tree

7 files changed

+76
-76
lines changed

7 files changed

+76
-76
lines changed

_posts/2012-12-04-elixir-v0-7-2-released.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ the type specification syntax.
1414

1515
Here's the gist:
1616

17-
{% highlight ruby %}
17+
{% highlight elixir %}
1818
@spec myfun(integer), do: integer
1919
# becomes
2020
@spec myfun(integer) :: integer

crash-course.markdown

+30-30
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ You may keep the shell running while you're editing the file. Just don't forget
5151

5252
Elixir too has an interactive shell called `iex`. Compiling Elixir code can be done with `elixirc` (which is similar to Erlang's `erlc`). Elixir also provides an executable named `elixir` to run Elixir code. The module defined above can be written in Elixir as:
5353

54-
{% highlight ruby %}
54+
{% highlight elixir %}
5555
# module_name.ex
5656
defmodule ModuleName do
5757
def hello do
@@ -62,7 +62,7 @@ end
6262

6363
And compiled from `iex`:
6464

65-
{% highlight ruby %}
65+
{% highlight elixir %}
6666
Interactive Elixir
6767
iex> c("module_name.ex")
6868
[ModuleName]
@@ -73,7 +73,7 @@ Hello world!
7373

7474
However notice that in Elixir you don't need to create a file only to create a new module, Elixir modules can be defined directly in the shell:
7575

76-
{% highlight ruby %}
76+
{% highlight elixir %}
7777
defmodule MyModule do
7878
def hello do
7979
IO.puts "Another Hello"
@@ -117,7 +117,7 @@ X + Y.
117117

118118
**Elixir**
119119

120-
{% highlight ruby %}
120+
{% highlight elixir %}
121121
x = 2; y = 3
122122
x + y
123123
{% endhighlight %}
@@ -152,7 +152,7 @@ ok
152152

153153
**Elixir**
154154

155-
{% highlight ruby %}
155+
{% highlight elixir %}
156156
iex> a = 1
157157
1
158158
iex> a = 2
@@ -178,13 +178,13 @@ orddict:new().
178178

179179
to invoke the `new` function from the `orddict` module. In Elixir, use the dot `.` in place of the colon `:`
180180

181-
{% highlight ruby %}
181+
{% highlight elixir %}
182182
Process.self
183183
{% endhighlight %}
184184

185185
**Note**. Since Erlang modules are represented by atoms, you may invoke Erlang functions in Elixir as follows:
186186

187-
{% highlight ruby %}
187+
{% highlight elixir %}
188188
:lists.sort [3, 2, 1]
189189
{% endhighlight %}
190190

@@ -212,7 +212,7 @@ X = 10.
212212

213213
**Elixir**
214214

215-
{% highlight ruby %}
215+
{% highlight elixir %}
216216
:im_an_atom
217217
:me_too
218218

@@ -235,7 +235,7 @@ is_atom(''). %=> true
235235

236236
**Elixir**
237237

238-
{% highlight ruby %}
238+
{% highlight elixir %}
239239
is_atom :ok #=> true
240240
is_atom :'ok' #=> true
241241
is_atom :"Multiple words" #=> true
@@ -259,7 +259,7 @@ setelement(1, { a, b, c }, d) % => { d, b, c }
259259

260260
**Elixir**
261261

262-
{% highlight ruby %}
262+
{% highlight elixir %}
263263
elem({ :a, :b, :c }, 0) % => :a
264264
setelem({ :a, :b, :c }, 0, :d) % => { :d, :b, :c }
265265
{% endhighlight %}
@@ -289,7 +289,7 @@ In Elixir, the word **string** means a utf-8 binary and there is a `String` modu
289289

290290
Elixir also supports multiline strings (also called heredocs):
291291

292-
{% highlight ruby %}
292+
{% highlight elixir %}
293293
is_binary """
294294
This is a binary
295295
spawning several
@@ -311,14 +311,14 @@ re:run("abc ", Pattern).
311311

312312
**Elixir**
313313

314-
{% highlight ruby %}
314+
{% highlight elixir %}
315315
Regex.run %r/abc\s/, "abc "
316316
#=> ["abc "]
317317
{% endhighlight %}
318318

319319
Regexes are also supported in heredocs, which is convenient to define multiline regexes:
320320

321-
{% highlight ruby %}
321+
{% highlight elixir %}
322322
is_regex %r"""
323323
This is a regex
324324
spawning several
@@ -344,7 +344,7 @@ Dict = orddict:from_list([{key, 10}, {another_key, 20}]).
344344

345345
**Elixir**
346346

347-
{% highlight ruby %}
347+
{% highlight elixir %}
348348
dict = [key: 10, another_key: 20]
349349
#=> [another_key: 20, key: 10]
350350
{% endhighlight %}
@@ -360,7 +360,7 @@ The syntax for records differs significantly between Erlang and Elixir. Please r
360360

361361
In order to translate Erlang records into Elixir records, use Record.extract(). For example, to use the `ec2_instance_spec` record from [erlcloud][8]:
362362

363-
{% highlight ruby %}
363+
{% highlight elixir %}
364364
defrecord :ec2_instance_spec, Record.extract(:ec2_instance_spec,
365365
from: "deps/erlcloud/include/erlcloud_ec2.hrl")
366366

@@ -402,7 +402,7 @@ Here we create a module named ``hello_module``. In it we define three functions,
402402

403403
An Elixir equivalent to the Erlang above:
404404

405-
{% highlight ruby %}
405+
{% highlight elixir %}
406406
defmodule HelloModule do
407407
# A "Hello world" function
408408
def some_fun do
@@ -423,7 +423,7 @@ end
423423

424424
In Elixir, it is also possible to have multiple modules in one file, as well as nested modules:
425425

426-
{% highlight ruby %}
426+
{% highlight elixir %}
427427
defmodule HelloModule do
428428
defmodule Utils do
429429
def util do
@@ -484,7 +484,7 @@ loop_through([]) ->
484484

485485
**Elixir**
486486

487-
{% highlight ruby %}
487+
{% highlight elixir %}
488488
def loop_through([h|t]) do
489489
IO.inspect h
490490
loop_through t
@@ -514,7 +514,7 @@ sum(A, B, C) -> A + B + C.
514514

515515
**Elixir**
516516

517-
{% highlight ruby %}
517+
{% highlight elixir %}
518518
def sum, do: 0
519519
def sum(a), do: a
520520
def sum(a, b), do: a + b
@@ -547,7 +547,7 @@ sum("a", "b").
547547

548548
**Elixir**
549549

550-
{% highlight ruby %}
550+
{% highlight elixir %}
551551
def sum(a, b) when is_integer(a) and is_integer(b) do
552552
a + b
553553
end
@@ -599,7 +599,7 @@ lists:map(Square, [1, 2, 3, 4]).
599599

600600
**Elixir**
601601

602-
{% highlight ruby %}
602+
{% highlight elixir %}
603603
sum = fn(a, b) -> a + b end
604604
sum.(4, 3)
605605
#=> 7
@@ -629,7 +629,7 @@ F({a, b}).
629629

630630
**Elixir**
631631

632-
{% highlight ruby %}
632+
{% highlight elixir %}
633633
f = function do
634634
{:a, :b} = tuple ->
635635
IO.puts "All your #{inspect tuple} are belong to us"
@@ -659,7 +659,7 @@ lists:map(fun square/1, [1, 2, 3]).
659659

660660
**Elixir**
661661

662-
{% highlight ruby %}
662+
{% highlight elixir %}
663663
def square(x) do
664664
x * x
665665
end
@@ -672,7 +672,7 @@ Enum.map [1,2,3], function(:square, 1)
672672

673673
Elixir supports partial application of functions which can be used to define anonymous functions in a concise way:
674674

675-
{% highlight ruby %}
675+
{% highlight elixir %}
676676
Enum.map [1, 2, 3, 4], &1 * 2
677677
#=> [2, 4, 6, 8]
678678

@@ -682,7 +682,7 @@ List.foldl [1, 2, 3, 4], 0, &1 + &2
682682

683683
Partials also allow us to pass named functions as arguments.
684684

685-
{% highlight ruby %}
685+
{% highlight elixir %}
686686
def square(x) do
687687
x * x
688688
end
@@ -713,7 +713,7 @@ end
713713

714714
**Elixir**
715715

716-
{% highlight ruby %}
716+
{% highlight elixir %}
717717
case { x, y } do
718718
{ :a, :b } -> :ok
719719
{ :b, :c } -> :good
@@ -750,7 +750,7 @@ Test_fun(10).
750750

751751
**Elixir**
752752

753-
{% highlight ruby %}
753+
{% highlight elixir %}
754754
test_fun = fn(x) ->
755755
cond do
756756
x > 10 ->
@@ -782,7 +782,7 @@ There are two important differences between Elixir's `cond` and Erlang's `if`:
782782

783783
Elixir also provides a `if` function that resembles more imperative languages and is useful when you need to check if one clause is true or false:
784784

785-
{% highlight ruby %}
785+
{% highlight elixir %}
786786
if x > 10 do
787787
:greater_than_ten
788788
else
@@ -811,7 +811,7 @@ end.
811811

812812
**Elixir**
813813

814-
{% highlight ruby %}
814+
{% highlight elixir %}
815815
pid = Process.self
816816

817817
pid <- { :hello }
@@ -834,7 +834,7 @@ Elixir compiles directly into BEAM byte code. This means that Elixir code can be
834834

835835
Consider the following module in Elixir:
836836

837-
{% highlight ruby %}
837+
{% highlight elixir %}
838838
defmodule Contrived do
839839
def pretty_binary(bin) do
840840
"Pretty " <> bin

0 commit comments

Comments
 (0)