Skip to content

set: Implement __or__ of set #84

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

Merged
merged 2 commits into from
Sep 17, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
set: create a new instance for the value returned
  • Loading branch information
DoDaek committed Sep 17, 2019
commit 8cc93532c1b7f5de3840e52a367f17017936e3a3
5 changes: 4 additions & 1 deletion py/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,14 @@ func (s *Set) M__and__(other Object) (Object, error) {
}

func (s *Set) M__or__(other Object) (Object, error) {
ret := s
ret := NewSet()
b, ok := other.(*Set)
if !ok {
return nil, ExceptionNewf(TypeError, "unsupported operand type(s) for &: '%s' and '%s'", s.Type().Name, other.Type().Name)
}
for j := range s.items {
ret.items[j] = SetValue{}
}
for i := range b.items {
if _, ok := s.items[i]; !ok {
ret.items[i] = SetValue{}
Expand Down