Skip to content

Instantly share code, notes, and snippets.

@lucianoschillagi
Created October 9, 2024 13:00
Show Gist options
  • Save lucianoschillagi/ed43c20b0b871cdf7a1ec2fd08ff6ad5 to your computer and use it in GitHub Desktop.
Save lucianoschillagi/ed43c20b0b871cdf7a1ec2fd08ff6ad5 to your computer and use it in GitHub Desktop.
converting an function into a computed property
import Foundation
struct Cat {
// func saySomething() -> String {
// return "Muuu! I mean 'Miau!'"
// }
// Now, I am going to convert this method into a computed property
var saySomething: String {
return "Muuu! I mean 'Miau!'"
}
}
let mishi = Cat()
mishi.saySomething
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment