Muco
Hello, everyone, I’m new to Elixir I’m reading a book entitled Phoenix in Action I’m on its second chapter where the author introduces to Elixir but I’m facing this error when I run it into the Elixir shell. This is here:
iex(5)> Fizzbuzz.go(1, 100)
** (CondClauseError) no cond clause evaluated to a truthy value
(fizzbuzz 0.1.0) lib/fizzbuzz.ex:11: Fizzbuzz.show_results/1
(elixir 1.10.1) lib/enum.ex:789: anonymous fn/3 in Enum.each/2
(elixir 1.10.1) lib/enum.ex:3371: Enum.reduce_range_inc/4
(elixir 1.10.1) lib/enum.ex:2116: Enum.each/2
And the code is here:
defmodule Fizzbuzz do
def go(minNumber, maxNumber) do
Enum.each(minNumber..maxNumber, fn number -> show_results(number) end)
end
def show_results(number) do
# IO.puts(number)
cond do
rem(number, 3) == 0 && rem(number, 5) == 0 -> IO.puts("FizzBuzz")
rem(number, 3) == 0 -> IO.puts("Fizz")
rem(number, 5) == 0 -> IO.puts("buzz")
end
end
end
But in the show_results function when I just add IO.puts(number) only I can see them in the console. I need your help, please.
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
kip
The message is telling you that there are no conditions within the
condexpression that evaluate totruthy. What should aconddo if no conditions are met? it raises an exceptionThe usual approach is to add a final condition that is guaranteed to evaluate to a
truthyvalue. Oftentrue. So:Muco
Thank you @kip for your response.
The thing that I’m not understanding is why there’s no truthy evaluated as I can see I have numbers from 1 to 100
Muco
Aah!! I actually got it so it means if it encounters nothing evaluated it will just stop the program and raise the exception ? Thank you again @kip
ityonemo
exactly. Also just be careful, the catch-all for
condistrue, and the catch-all forcaseis_(or any variable), It’s easy to get confused if you refactor one to the other.chrisdel101
I had this same question. The first run of
condhad no truthy values so gave an error. Adding a default end condition using thetrue -> "do stuff"solved it.