During a mentoring session, I noticed the mentoring notes for Elixir’s Lasagna states the following points:
If a solution uses names like
is_cooked
andis_ready
, it can be pointed out that Elixir has the following naming convention:
is_foo
should only be used for macros that can be used in guard clauses,foo?
should be used otherwise.…
This exercise can be solved without regular expressions and a student could be encouraged to try to do that.
- Regular expressions are not known for their readability.
String.ends_with?(input, "?")
is more obvious thanRegex.match?(~r/\?$/, input)
.- It is a good habit to use simple tools for simple problems and advanced tools for advanced problems.
- Elixir developers should be familiar with the
String
module and the functions it offers.Hint functions for the truly stuck
String#trim/1
String#ends_with?/2
String#downcase/2
String#upcase/2
String.upcase(input) != String.downcase(input)
if there is a letter present.
I suspect the notes are for a different exercise or outdated? I don’t see why a student would name a method like is_cooked
, use regular expressions or need to use any of the string functions in this exercise (the example solution at the top of the page doesn’t even have any of those things)…