Question

Why does this work:

iex(9)> Enum.filter(["lowks", "kian", "seong"], fn(x) -> x == "lowks" end)
["lowks"]

While this does not:

iex(5)> Enum.filter(String.split("low kian seong"), fn(x) -> x == "lowks" end) []

Is it because I am filtering the function ?

Was it helpful?

Solution

Unless I'm missing something, you have a typo in the second example. It should be lowks not low.

iex(1)> Enum.filter(String.split("lowks kian seong"), fn(x) -> x == "lowks" end)
["lowks"]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top