#TIL #erlang 함수를 호출할 때는 문자열 타입이 charlist인 걸 기억
2019-01-23iex> :dets.open_file(:storage, [{:type, :set}, {:file, "file"}]) ** (ArgumentError) argument error
argument error 뜨면 속 터진다. 원인을 찾아 헤매야 한다.
=”file”= 인자가 잘못됐다. 문자열로 binary를 사용해서 에러가 났다. elixir에서 erlang 함수를 호출했기 때문에 binary가 아니라 charlist를 인자로 넘겨야 한다. elixir에서 byte 시퀀스를 binary라고 부른다.
iex> :dets.open_file(:storage, [{:type, :set}, {:file, 'file'}])
=’file’= 인자를 넘기면 된다. Kernel.to_charlist/1 함수를 호출해도 된다.
참고
- :dets.open_file argument error - stackoverflow.com
- What is a binary? What is a bitstring? What is a charlist? - reddit.com
- Binaries, strings, and charlists - elixir-lang.org
- category:
- til 174
- tags:
- elixirlang 35
@ohyecloudy
, ohyecloudy@gmail.com