Questions tagged [swift-playground]

Swift Playgrounds are interactive design environments that evaluate code as you write it. Intermediate results of the code are shown in a right-hand pane.

Swift playgrounds are interactive documents where Swift code is compiled and run live as you type. Results of operations are presented in a step-by-step timeline as they execute, and variables can be logged and inspected at any point. Playgrounds can be created within an existing Xcode project or as standalone bundles that run by themselves.

Playgrounds provide a great opportunity to document functions and library interfaces by showing syntax and live execution against real data sets. For the case of the collection functions, we’ve created the CollectionOperations.playground, which contains a list of these functions, all run against sample data that can be changed live.

Playgrounds allow you to edit the code listings and see the result immediately.

The new playgrounds are especially useful for educators. You can insert rich instructional content with paragraph headings, diagrams, and links to additional material alongside the interactive Swift code.

New features in Xcode 6.3 playgrounds include the following:

  • Inline results display the output of your Swift code within the main editor window. The results area can be resized and configured to show different views of the output.

  • Stylized text is easy to add to your playground by adding special markup to your comments based on the familiar Markdown syntax. Some available styles are headings, bold, italic, lists, bullets, and links to external or bundled resources.

  • The Resources folder bundles images and other content directly within the playground. These resources can be accessed from your Swift code or from the rich comments within the playground. (Note: with Xcode 6.3 beta 2 use Show Package Contents in Finder to drag files into the playground’s Resources folder.)

Apple provides documentation here:

1311 questions
-4
votes
3 answers

Non optional String automatically getting changed to optional

I am facing a problem where the object which I have created is a non-optional value but somehow it is getting converted into an optional one. I have tried in the playground also refer to the screenshot below. Does anyone know what am I missing?
Khushal Dugar
  • 230
  • 4
  • 12
-4
votes
1 answer

How do you find something in a dictionary without knowing the name of the dictionary

I’m using Swift playgrounds the “Anwsers Template” Let’s say I have: Let apple = [“cost”: 10, “nutrition”: 5] Let banana = [“cost”: 15, “nutrition”: 10] Let choice = askForChoice(Options:[“Apple”, “Banana”]) What is a good, easy way of finding the…
John Song
  • 3
  • 3
-4
votes
2 answers

Swift array declaration

I want to declare an array in a Swift Playground, but doing it this way var lengths: [Int] = [] produces a Consecutive statements on a line must be separated by ';' error. However, declaring the array this other way, works perfectly var lengths:…
amb
  • 4,798
  • 6
  • 41
  • 68
-5
votes
2 answers

Why 100/1000 is not 0.10 in swift palyground?

I am facing a problem where I am not getting values of decimal places here is the code that I used to run in Swift Playground print(100/1000) print(Float(100/1000)) Expected Output : 0.10 0.10 Actual Output: 0 0.0
Varun Naharia
  • 5,318
  • 10
  • 50
  • 84
-5
votes
1 answer

How to attach Particle system to 'bottom' of node

I'm trying to get flame particle system to appear from a nozzle but instead of it appearing at the bottom of the nozzle the particles appear from the top making it look like the nozzle is on fire. Particle systems do have a Position property…
Junaid
  • 321
  • 1
  • 4
  • 15
-5
votes
1 answer

Insert node in singly linked list in swift playground

Given a singly linked list, the task is to write a program to insert that element in a linked list in Swift.
CrazyPro007
  • 1,006
  • 9
  • 15
1 2 3
87
88