Guard clauses allow Elixir to determine which function to invokebased not only on which arguments are passed, but also based ontype or some tests involving their values. Guard clauses are definedusing the when
keyword.
Examples:
External, extract fl, fld fluid g gram gr grain gtt drop H hypodermic. Medication Abbreviations for Drug Orders Cheat Sheet by deleted via. Home Instant Answers Elixir Cheat Sheet Next Steps. This is the home page for your Instant Answer and can be.
Additionally, users may define their own guards. Example: the Bitwise
module defines bnot
, ~~~
, band
, &&&
, bor
, |||
, bxor
, ^^^
,bsl
<<<
, bsr
>>>
.
Operators
, | |
Unary operators | |
Short-circuiting operators | |
| |
Test membership in a list or range with Example: |
Functions
See main Elixir documentation for more information.
| |
See main Elixir documentation for more information.
|
Notes
- Based on 'Expressions in guard clauses' from Elixir-Lang Getting Started Guide
Hi everyone! 🙂
It’s been a while since I last updated this blog and a lot of things has surely happen – new technologies, new projects, new hobbies — indeed a lot of new things. One year surely flew fast!
So for this comeback post, I’ll share with you today my notes on installing an Elixir/Phoenix setup on a Mac OSX. The first time I did this was a year ago and I had to do it again last week — not much have changed but just thought of documenting it in case it’ll also help anyone out there.
So first, what is Elixir? Regular readers of this blog might have noticed that this is the first post that mentioned it. Elixir is a functional programming language that is built for distributed and fault-tolerant systems. Elixir compile to Erlang bytecode which then runs on BEAM (Erlang’s VM). Before we proceed with Elixir, what then is Erlang? Erlang is also a concurrent functional programming language that first appeared in the 1980’s which was used mainly back then for telecommunications to support hundreds of thousands of concurrent communications. It was developed in the Ericsson company by Joe Armstrong and company.
With this awesomeness of Erlang, Elixir leverages it by running on top of the Erlang VM and providing a syntax and feel that is reminiscent of more modern programming language such as Ruby and Python making it a top choice for writing embedded software application as well as web applications.
And on this post, we shall be seeing Phoenix – an MVC web framework running with Elixir. Let’s get started!
INSTALLATION NOTES:
To setup a running Phoenix app, we need to set up the prerequisites first before we install Phoenix.
1. Install Elixir via HomeBrew
2. Install the Hex Package Manager
3. Check the Elixir version
* Phoenix requires Elixir 1.4 (or later) and Erlang 18 (or later). Your output would look something like this:
4. Install the Mix Phoenix Archive
* This contains the Phoenix application as well as the compiled BEAM files
5. Install NodeJS (Optional)
Elixir Cheat Sheet
By default Phoenix uses brunch.io to compile your app’s static assets. Brunch.io on the other hand requires the Node Package Manager (NPM) to install its dependencies and NPM requires nodeJS. If you wish to not install NodeJS, you may skip this step and head to the Installation Verification section below.
a. Install NVM
To install NodeJS, let’s first install the Node Version Manager (NVM). NVM provides a way to organize and switch between several version of NodeJS in your system. Developers who have experienced working with several projects requiring different NodeJS versions appreciate the importance of this. To install Phoenix, we’ll be using only one version but since we’re already setting it up, let’s do it the right way.
After running the above command, the following lines will be available in your ~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc.
It installed mine in ~/.bashrc though nvm still wasn’t by my terminal even if I already restarted it so added the above lines to my ~/.bash_profile too and it already worked!
b. Install NodeJS via NVM
Once it’s done, we can verify that NodeJS is indeed installed:
INSTALLATION VERIFICATION
a.k.a. Creating our first app!
1. Create a Phoenix app
2. Run the server
Note: You may need to run mix ecto.create in case you encounter the following error,
Elixir Cheat Sheet Pdf
And yay, that’s it! You now have a up and running Phoenix installation. 🙂
So that’s it for this post and hope to see you again in my future posts! Will be sure to write more on Elixir and Phoenix.
Potion Cheat Sheet
See you! ❤
Elixir Genserver Cheat Sheet
References: