Alquimia 2.1
Interactive Elixir
import IEx.Helpers
h(String.chunk())
i("string")
i(fn -> IO.puts "Using function")
Basic Types
number = 10
second_number = number
number = 5
second_number
Integer.to_string(20)
Integer.parse("10.20")
10 / 2
Float
float_n = 10.0
Float.round(20.5)
Float.ceil(10.1)
Float.floor(10.1)
String
my_str = "This is a string"
not_a_string = 'This is not a string'
is_binary(not_a_string)
String.valid?(my_str)
"Best Tv Show of all time is " <> "Breaking Bad"
string_to_interpolate = "Breaking Bad"
"Best Tv Show of all time is #{string_to_interpolate}"
string_to_interpolate = 24
"My age is #{string_to_interpolate}"
String.length("A Kingdom so far far away")
String.contains?("The kingdom of my Father", "Father")
String.upcase("long may live elixir!")
String.downcase("DO OR DO NOT, THERE IS NO TRY")
Charlists
list = 'This is a charlist'
'a' == [97]
String.Chars.to_string(list)
Bitstrings
<<97>> == "a"
Binaries
is_binary(<<97::8>>)
is_bitstring(<<5::4>>)
is_binary("every string is a binary")
Atoms
atom = :atom
is_atom(atom)
defmodule MyAtomModule do
end
is_atom(MyAtomModule)
String.to_atom("is_an_atom")
String.to_existing_atom("not_an_atom")
Booleans
true == true
if nil, do: :ok, else: :not_ok
true == true
false == false
Lists