Muhammad Lukman Low
Muhammad Lukman Low

Reputation: 8533

Some help needed with guard expression in Elixir

I am trying to write a guard expression for my function which will not accept char lists, so I do this:

def myfunction(path) when is_list(path) do

the problem here is that is_list also returns true when a character list such as 'path' is given, how would I go about this?

Upvotes: 2

Views: 315

Answers (1)

Benjamin Tan Wei Hao
Benjamin Tan Wei Hao

Reputation: 9691

You could try is_binary. Will return true for Strings, false for Lists in the way you define it.

Upvotes: 2

Related Questions