Search code examples
swiftswift-playground

Swift Dictionary is not printing key values


I am new to swift programming. I have written the following code for iterating and printing dictionary

var items_price = [
"milk": 1 ,
"bread" : 3,
"egg" : 2
]

for (myKey, myValue) in items_price {
      println ("\(myKey) costs : \(myValue)")
}

This code is not printing the result as "milk costs: 1" ,etc. What is wrong?


Solution

  • println statements are printed in timeline of playgrounds. Press the "+" in the circle at the end of print statement line. enter image description here