Introduction to the Swift REPL

Introduction to the Swift REPL (source)

Xcode 6.1 introduces yet another way to experiment with Swift in the form of an interactive Read Eval Print Loop, or REPL. Developers familiar with interpreted languages will feel comfortable in this command-line environment, and even experienced developers will find a few unique features. To get started, launch (found in /Applications/Utilities) and type “swift” at the prompt in OS X Yosemite, or “xcrun swift” in OS X Mavericks. You’ll then be in the Swift REPL:

Welcome to Swift version 1.1 (swift-600.0.20.0). Type :help for assistance.

All you need to do is type Swift statements and the REPL will immediately execute your code. Expression results are automatically formatted and displayed along with their type, as are the results of both variable and constant declarations. Console output flows naturally within the interactive session: Continue reading


How to set ‘Safe Sleep’ on Mac OS X?

There could be times when you would need to be able to restore your programs in an event of a power outage. I’m assuming that this power outage is not a sudden one and your system would be given time to save the contents of RAM to hard disk or any other external storage medium. Like your UPS has started beeping to warn that it is going to shut down and you would turn your system to safe sleep. Continue reading

Mac Terminal

There could be times when you’ll find the terminal to be quick at performing tasks than using graphical interface. If you use the terminal often, it would be handy to use commands from the terminal history. You can search history as follows:

  1. Up/Down Arrow Keys
  2. Control+R
    start typing to narrow down search and escape/enter the searched command and using arrow keys now would navigate from the history from that particular point back n forth.