Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Prefer implicit getters on computed properties #1

Merged
merged 4 commits into from
Jul 22, 2014

Conversation

jspahrsummers
Copy link
Contributor

Proposed by @robrix in ReactiveCocoa/ReactiveCocoa#1382 (comment).

/cc @github/mac


Style guide & coding conventions for Swift projects
When possible, omit the `get` keyword on computed properties that cannot be written to.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

immutable properties

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's strictly accurate, because a read-only property might not be idempotent. Unless you intended that anything following this style should be?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. read-only properties then.

@robrix
Copy link
Contributor

robrix commented Jul 13, 2014

Suggest calling out subscript specially as well.

@jspahrsummers
Copy link
Contributor Author

@robrix Can you demonstrate what you mean?

@robrix
Copy link
Contributor

robrix commented Jul 15, 2014

For read-only subscripts, do:

subscript (index: Int) -> T {
    
}

not:

subscript (index: Int) -> T {
    get {
        
    }
}

@joshvera
Copy link

👍

@alanjrogers
Copy link

👍👍

@jspahrsummers
Copy link
Contributor Author

💳

@robrix robrix self-assigned this Jul 22, 2014
@robrix
Copy link
Contributor

robrix commented Jul 22, 2014

:shipit:

robrix added a commit that referenced this pull request Jul 22, 2014
Prefer implicit getters on computed properties
@robrix robrix merged commit 334ec03 into master Jul 22, 2014
@robrix robrix deleted the jspahrsummers-patch-1 branch July 22, 2014 18:18
robrix pushed a commit that referenced this pull request Mar 23, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants