-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
add setutils.[]= #17272
add setutils.[]= #17272
Conversation
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.
It is not very intuitive, do other language have similar features?
http://www.cplusplus.com/reference/bitset/bitset/operator[]/ |
in D:https://dlang.org/library/std/bitmanip/bit_array.html import std.bitmanip;
void main(string[]args){
auto b = BitArray([1, 0]);
assert(b[0] == true);
b[0] = false;
assert(b[0] == false);
} in C++#include <bitset>
#include <cassert>
int main (int argc, char *argv[]) {
std::bitset<128> a;
a[3] = true;
assert(a[3] == true);
return 0;
} in swift:https://victorqi.gitbooks.io/swift-algorithm/content/bit_set.html var bits = BitSet(size: 140)
bits[2] = true |
065518e
to
518eac7
Compare
I do like the feature but really dislike the syntax, I'm suggesting |
well vote as reaction to this comment:
otherwise, add a comment for a different suggestion. |
518eac7
to
074c8a9
Compare
* add setutils.[]= * address comments * proc => func (for other symbols too)
* add setutils.[]= * address comments * proc => func (for other symbols too)
now that we have a dedicated
std/setutils
, it makes sense to add this syntax sugar, which is useful in particular when the value (true or false) isn't hard-coded, thus avoidingif ... incl else ... excl
future work
func
[]=*[T](s: var set[T], arg: set[T], val: bool) {.inline.} =
=> Added setutils.[]= variant #17302