Skip to content

Instantly share code, notes, and snippets.

@geykel
Created January 28, 2016 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geykel/c1620b054909daeea929 to your computer and use it in GitHub Desktop.
Save geykel/c1620b054909daeea929 to your computer and use it in GitHub Desktop.
// 1
protocol NombreCompleto {
var nombreCompleto:String { get }
}
// 2
class Persona: NombreCompleto {
// 3
var nombre: String
var apellidos: String
// 4
init(nombre: String, apellidos: String) {
self.nombre = nombre
self.apellidos = apellidos
}
// 5
var nombreCompleto: String {
// 6
return "(nombre) (apellidos)"
}
}
// 7
var juan = Persona(nombre: "Juan", apellidos: "Pérez")
// 8
print(juan.nombreCompleto)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment