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

Stdlib Sets docs error #1096

Open
calindragomir opened this issue Feb 20, 2022 · 1 comment
Open

Stdlib Sets docs error #1096

calindragomir opened this issue Feb 20, 2022 · 1 comment

Comments

@calindragomir
Copy link

The documentation here reads:

The apply method for a set is the same as contains, so set(elem) is the same as set contains elem.

I believe you meant the other way around.

The apply method for a set is the same as set(elem), so contains is the same as set contains elem.

I wanted to push a fix for this myself, but I can't seem to find sources for the docs there.

@jisantuc
Copy link

Hi @calindragomir! As written, the statement is true --

@ val s = Set('a', 'b', 'c', 'd')
s: Set[Char] = Set('a', 'b', 'c', 'd')

@ s contains 'a'
res1: Boolean = true

@ s('a')
res2: Boolean = true

@ s('e')
res3: Boolean = false

@ s contains 'e'
res4: Boolean = false

The apply method on s (s with (someElem) after it) indeed tests the same thing that s contains someElem does. I think, looking through where these exercises are defined, that apply method on x being a synonym for x() hasn't been introduced before the Sets exercise -- is that correct?

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