HashMap constructor usage

30 views
Skip to first unread message

Nikolay Rychkov

unread,
Jul 3, 2015, 11:18:22 AM7/3/15
to ceylon...@googlegroups.com
All parameters of HashMap constructor are defaulted. I would like to create HashMap like this:
Map<String, String> = HashMap({"key" -> "value"})

Unfortunately, I got an error "Argument must be assignable to parameter stability of HashMap: {<String->String>+} is not assignable to Stability"
I.e. compiler is not able to recognize that I want to use just third argument. 

How to avoid this behaviour? What is a general rule of recognizing defaulted arguments? 

Stephane Epardaud

unread,
Jul 3, 2015, 11:47:30 AM7/3/15
to ceylon...@googlegroups.com
Using `()` for the invocation means positional invocation. Used "named parameter" invocations with `{}` as such:

Map<String, String> = HashMap{"key" -> "value"}

--
You received this message because you are subscribed to the Google Groups "ceylon-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceylon-users...@googlegroups.com.
To post to this group, send email to ceylon...@googlegroups.com.
Visit this group at http://groups.google.com/group/ceylon-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceylon-users/47248f34-9079-48c3-a040-82501ed30040%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Stéphane Épardaud
Reply all
Reply to author
Forward
0 new messages