Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support subscript setters #37

Open
harlanhaskins opened this issue Mar 5, 2017 · 2 comments
Open

Support subscript setters #37

harlanhaskins opened this issue Mar 5, 2017 · 2 comments

Comments

@harlanhaskins
Copy link
Collaborator

harlanhaskins commented Mar 5, 2017

Subscripts are currently get-only, which means you can't override the setting behavior.

Something like this should work

type Foo {
  subscript(_ v: Int) -> Int {
    get { return 4 }
    set { print("you gave me"); println(newValue) }
  }
}
@segiddins
Copy link
Contributor

Should a SubscriptSetExpr return anything or just void? (I personally like setters returning the set value)

@harlanhaskins
Copy link
Collaborator Author

I actually think setters should be void

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants