top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Dictionary in SWIFT throws error

0 votes
311 views

Dictionary gives error when i tried to re-assign values.

  var dictionary = [:]
    dictionary = ["one":"Hello","two":"Good","three":"Morning"]
    println(dictionary)
    dictionary["two"] = "Night"
    println(dictionary)

And error is

Playground execution failed: error: <REPL>:35:17: error: cannot assign to the result of this expression
dictionary["two] = "Night"
~~~~~~~~~~~~~~~ ^
posted Jul 22, 2014 by Arun

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Assign values separately as below

var d1: Dictionary = [:]
d1["asdf"] = 1
d1["qwer"] = "qwer"
answer Aug 4, 2014 by Raju
Similar Questions
0 votes

How to create mutable or immutable Array/Dictionary in SWIFT as like in objective c

0 votes

how to handle exceptions which occurs during run time in SWIFT

+1 vote

How to declare single parameter which accept multiple values.

+1 vote

How to use default values for parameter in function. What will happens when value is not passed for a default parameters.

0 votes

I am facing situation to use external parameter name to a function parameter name .. How to achieve this

...