Erlang – term_to_binary

Erlang term_to_binary

In this guide, we will discuss Erlang term_to_binary. This method is used to convert a term to binary.

Syntax

term_to_binary(term)

Parameters

  • term − This is the term value which needs to be converted to a binary value.

Return Value

Returns a binary value based on the term specified.

For example

-module(helloworld). 
-export([start/0]). 

start() -> 
   io:fwrite("~p~n",[term_to_binary("hello")]).

Output

When we run the above program we will get the following result.

{<<131,107,0,5,104,101,108,108,111>>}

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply