-
-
Notifications
You must be signed in to change notification settings - Fork 162
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
[builtins/dict] add => values() method #1777
Conversation
btw the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thank you!
How about filling in a one line description for keys() and values() in doc/ref/chap-type-method.md
?
And perhaps 2 examples like the ones in start() end()
etc.
I've been doing that lately, we are slowly creeping up :-)
builtin/method_dict.py
Outdated
dictionary = rd.PosDict() | ||
rd.Done() | ||
|
||
keys = [k for k in dictionary.values()] # type: List[value_t] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be called values
or v
or vals
:-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reminder :)
Oh also I think it should just be
vals = dictionary.values()
No need for list comprehension
In the keys() case we need the list comprehension, because we have to add the value.Str()
wrapper
I hated the emptiness of that page so I added more examples… Used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the documentation! much appreciated
doc/ref/chap-type-method.md
Outdated
Add an element to a list. | ||
|
||
var fruits = :|apple banana pear| | ||
call fruits -> append("orange") # returns null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to encourage a style of no space for ->, but spaces for
=>` to make it look more different?
call fruits->append('orange')
vs.
var v = d => values() => reversed()
Because =>
can be chained and ->
can't. ->
generally has no return value
What do you think?
builtin/method_dict.py
Outdated
dictionary = rd.PosDict() | ||
rd.Done() | ||
|
||
keys = [k for k in dictionary.values()] # type: List[value_t] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reminder :)
Oh also I think it should just be
vals = dictionary.values()
No need for list comprehension
In the keys() case we need the list comprehension, because we have to add the value.Str()
wrapper
Oh just to clarify the types a bit, there are extra "wrappers" for YSH level vs. "mycpp" level: Here's the type of a mycpp str:
and mycpp dict:
From
And then a mycpp Dict with a value.Str:
And then a YSH dict!
So yeah these extra wrappers take a bit of getting used to! |
Thanks for your patience with me! |
Thank you! I'm going to put this on #help-wanted as another great example |
C++ probably fails because I don't wrap the elements in a
value.X
but we'll see :)