<!--
{
  "documentType" : "article",
  "framework" : "Swift Playgrounds",
  "identifier" : "/documentation/Swift-Playgrounds/hiding-code-from-a-playground-page",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Hiding Code from a Playground Page"
}
-->

# Hiding Code from a Playground Page

Use special Swift comments to hide code from display but continue to run it.

## Overview

You can hide code that’s unrelated to the main content of a playground page, like
calls to page setup functions, code for assessing the learner’s progress, and functions
in editable examples. Hidden code is still executed when the learner runs the playground.

Place code you want to hide between the `hidden-code` and `end-hidden-code` delimiters.

![Diagram showing the hidden-code and end-hidden code comment syntax. The first line is “//#-hidden-code”, followed by a placeholder line, terminated with a line with contents “//#-end-hidden-code”.](images/com.apple.Swift-Playgrounds/hiding-code-from-a-playground-page-1@2x.png)

The following shows the raw syntax for a playground page with hidden code.

```swift
//#-hidden-code
import UIKit
import PlaygroundSupport
let viewRect = CGRect(x: 0, y: 0, width: 100 , height: 400)
let theView = CustomView(frame: viewRect)
PlaygroundPage.current.liveView = theView
//#-end-hidden-code
//#-editable-code
theView.markColor = UIColor.darkGray
theView.isChecked = true
//#-end-editable-code
```

The following shows how the previous code appears when it’s rendered in the playground
page source editor.

```swift
theView.markColor = UIColor.darkGray
theView.isChecked = true
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)