简体   繁体   中英

Syntax error for inet parse_address command in elixir

I am new to elixir . My task to check if the given string is an ip address or a number . I found that inet has this parse_address which checks if the given string is an ip address or not and provides the appropriate response.

My code on the iex terminal is as follows

inet :parse_address("192.168.42.2")

When I run the above code on the terminal I get the following error

 iex(1)> inet :parse_address("192.168.42.2").
 ** (SyntaxError) iex:1: syntax error before: '('

Can somebody help me with this issue?

It should be

:inet.parse_address('192.168.42.2')

because module names are just atoms but in erlang, they start with a lowercase letter.

There is a lot of articles covering the subject on Erlang interoperability, one of those is here -> https://elixirschool.com/en/lessons/advanced/erlang/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM