Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Object-Oriented Swift 2.0 Complex Data Structures Adding Instance Methods

Ryan Maneo
Ryan Maneo
4,342 Points

Didn't work

I did it exactly how it asked, and it will not work. It compiled perfectly in Xcode also...

structs.swift
struct Person {
    let firstName: String
    let lastName: String

    func getFullName() -> (String) {
        return firstName + " " + lastName
    }}

let aPerson = Person(firstName: "Ryan", lastName: "Minnick")
let fullName = aPerson.getFullName()

2 Answers

Nathan Tallack
Nathan Tallack
22,159 Points

Great work! Very close. No need to put brackets around the return type.

struct Person {
    let firstName: String
    let lastName: String

    func getFullName() -> String {  // No brackets around return type.
        return firstName + " " + lastName
    }}

let aPerson = Person(firstName: "Ryan", lastName: "Minnick")
let fullName = aPerson.getFullName()

No idea why workspace cares about this. While it is not "required" it is not syntatically incorrect. But one thing I have learnt about workspaces is it does not like things that are not required. ;)

is that because of parsing? o _raw_intNS

Nathan Tallack
Nathan Tallack
22,159 Points

Not sure. All I know is workspaces cares about syntatic perfection. ;)