one-liner function to print hello world in swift

You can create a one-liner function to print "Hello, World!" in Swift using the following code:

main.swift
func sayHello() { print("Hello, World!") }

sayHello()
55 chars
4 lines

This code defines a function called sayHello, which simply prints "Hello, World!" when called. The function is then invoked with sayHello() to produce the desired output.

related categories

gistlibby LogSnag