[erlang-questions] How to insert null value into map

Brujo Benavides <>
Wed Sep 13 15:02:05 CEST 2017


Palanikumar:

	On one hand, you should show us what’s in your Some variable.
	On the other hand, you don’t seem to be using maps:get/3 as it’s intended to be used (check the docs <http://erldocs.com/20.0/stdlib/maps.html?i=1&search=maps:get#get/3>).
	Even more so, you should know that in Erlang variables start with an uppercase letter, that’s why in your example NULL is a variable name (not a value). See how Erlang VM tells you that the variable ‘NULL’ is unbound.

	Hope this helps,
	Cheers!

Brujo Benavides <http://about.me/elbrujohalcon>



> On Sep 13, 2017, at 09:50, Palanikumar Gopalakrishnan <> wrote:
> 
> Hi Hugo,
> 
>                 Null value showed in sql
> 
>  +---------------------+
> | NULL                |
> | NULL                |
> +---------------------+
> 
> When we applied it with map like below, It returns the following error
> ()27> maps:get("A", NULL, Some).
> * 1: variable 'NULL' is unbound
> ()28> 
> 
> 
> 
> 
> 
> 
> 
> On 13 September 2017 at 17:35, Hugo Mills < <mailto:>> wrote:
> On Wed, Sep 13, 2017 at 05:01:37PM +0530, Palanikumar Gopalakrishnan wrote:
> > Hi Guys,
> >                 I want to get data from mysql and append them into map. But
> > some row had null values. Hence i cant able to convert the null value into
> > map. Its there any way to convert null value into map.
> 
>    Why can't you put nulls into a map? This works, for example:
> 
> 2> #{null => null}.
> #{null => null}
> 
> so we can clearly put some null atom in both key and value positions
> in a map.
> 
>    If you could show an example row without a null, and what that
> turns into when you put it in a map, and then show how this fails when
> you do have a null, then it might be easier to answer your question.
> 
>    Hugo.
> 
> --
> Hugo Mills             | Klytus! Are your men on the right pills? Maybe you
>  carfax.org.uk <http://carfax.org.uk/> | should execute their trainer!
> http://carfax.org.uk/ <http://carfax.org.uk/>  |
> PGP: E2AB1DE4          |                      Ming the Merciless, Flash Gordon
> 
> 
> 
> -- 
> 
> Warm Regards,
> 
> Palanikumar Gopalakrishnan 
> Developer
> 
> 
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170913/9c5ffa05/attachment.html>


More information about the erlang-questions mailing list