loading...

Write With Me (Day 8)

matt24ray profile image matt24ray ・2 min read

Welcome to the 8th day of the Write With Me challenge. Earlier last week I asked the Dev.to community if they could give me the best tools tips and guides for Elixir, and it did not disappoint.

There were a lot of solid resources. Now I have a lot of work to do, and I have no excuses to not learn Elixir. I spend most of my time at DailyDrip maintaining our newsletter, but it has been so great to have support from my work and the dev community to try and learn Elixir.

Today, I needed to lowercase all the letters I had in a sentence. Typiclly I have a site that I go to that I just dump in the paragraph I need lowercased, and push a button, and voilà.

However, today was different. My gut was to accomplish the small task in an iex session.

So, I popped open iex.

λ iex
Interactive Elixir (1.6.6) - press Ctrl+C to exit (type h() ENTER for help)
iex>

Typed in the string I needed to be lowercased and it assigned it to a variable.

iex> words = "These Are Words"
"These Are Words"

Then, I wrongly guessed to call 'String.lowercase', which didn't work.

iex> String.lowercase(words)
** (UndefinedFunctionError) function String.lowercase/1 is undefined or private. Did you mean one of:

      * downcase/1
      * downcase/2

    (elixir) String.lowercase("There Are Words")

But... Wait. Read that error again... It tells you what you probably meant to do. Awesome! Let's try downcase.

iex> String.downcase(words)
"these are words"

It works. Awesome! Thanks iex!

Discussion

pic
Editor guide
Collapse
eli profile image
Eli Bierman

Nice post. It always surprises me how helpful Elixir's error suggestions are!