orville

orville

From Ruby to Elixir: Stuck at the start (page 20)

I managed to install asdf, then erlang and elixir via asdf.

I was able to create and test the example Mix project (page 19) successfully.

I’m confused where to put the very first example: one.ex with two functions (hello/0 and welcome/1). The filenames given start with elixir_examples/lib so I assumed that ‘lib’ is the same lib directory created on page 19, and thus created the one.ex file in a new examples/modules directory. However, running iex as shown on page 21 generates a “function Examples.Modules.One.hello/0 is undefined (module Examples.Modules.One is not available)” error message. I am invoking $ iex -S mix from the same directory that contains lib and mix.exs.

I’ve played around for a couple hours and am stumped. Thanks in advance for a hint!

1 166 3

Most Liked

orville

orville

The primary cause was a typo in the “defmodule” in one.ex.

However, I still find the path to the example files confusing: just prior to setting up the examples, the book has us run “mix new examples” (p19) which creates a new folder, “examples,” which contains a “lib” folder where we are to place our source code. The first example on the following page, however, places the “one.ex” in a path that has those folder names in reverse: “elixir_examples/lib/examples/modules/one.ex” so it’s confusing, especially since the top-level directory is different than the “examples” directory just created, and then we have to add two empty directories inside lib (including a confusing second instance of “examples”.

I think I understand it now, but I found it a bit confusing. Enjoying working through the rest of the otherwise excellent book, though!

Popular Prag Prog topics Top

jimschubert
In Chapter 3, the source for index introduces Config on page 31, followed by more code including tests; Config isn’t introduced until pag...
8 1308 3
New
jeffmcompsci
Title: Design and Build Great Web APIs - typo “https://company-atk.herokuapp.com/2258ie4t68jv” (page 19, third bullet in URL list) Typo:...
8 1916 7
New
sdmoralesma
Title: Web Development with Clojure, Third Edition - migrations/create not working: p159 When I execute the command: user=> (create-...
5 1082 2
New
jdufour
Hello! On page xix of the preface, it says there is a community forum "… for help if your’re stuck on one of the exercises in this book… ...
3 1138 1
New
swlaschin
The book has the same “Problem space/Solution space” diagram on page 18 as is on page 17. The correct Problem/Solution space diagrams ar...
1 1068 1
New
AufHe
I’m a newbie to Rails 7 and have hit an issue with the bin/Dev script mentioned on pages 112-113. Iteration A1 - Seeing the list of prod...
0 2610 9
New
Henrai
Hi, I’m working on the Chapter 8 of the book. After I add add the point_offset, I’m still able to see acne: In the image above, I re...
1 1017 4
New
EdBorn
Title: Agile Web Development with Rails 7: (page 70) I am running windows 11 pro with rails 7.0.3 and ruby 3.1.2p20 (2022-04-12 revision...
0 1127 1
New
dtonhofer
@parrt In the context of Chapter 4.3, the grammar Java.g4, meant to parse Java 6 compilation units, no longer passes ANTLR (currently 4....
0 1003 3
New
mcpierce
@mfazio23 I’ve applied the changes from Chapter 5 of the book and everything builds correctly and runs. But, when I try to start a game,...
0 1151 10
New

Other popular topics Top

PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
118 7074 30
New
AstonJ
Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: asdf install erlang 23.1.2 Configure failed. checking ...
10 5387 8
New
Exadra37
I am a Linux user since 2012, more or less, and I always use Ubuntu on my computers, and my last 2 laptops have been used Thinkpads, wher...
64 2945 29
New
AstonJ
I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me. I think the Planck and the Preonic (o...
105 14087 47
New
AstonJ
This looks like a stunning keycap set :orange_heart: A LEGENDARY KEYBOARD LIVES ON When you bought an Apple Macintosh computer in the e...
14 5805 7
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
10 4951 6
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
21 10871 7
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
21 5395 9
New
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File > New Rule: And select Deny, O...
5 7401 3
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
37 3003 14
New

Latest in PragProg

View all threads ❯