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

Enum should be a scalar for broadcast #30669

Closed
stevengj opened this issue Jan 9, 2019 · 3 comments
Closed

Enum should be a scalar for broadcast #30669

stevengj opened this issue Jan 9, 2019 · 3 comments
Labels
broadcast Applying a function over a collection good first issue Indicates a good issue for first-time contributors to Julia

Comments

@stevengj
Copy link
Member

stevengj commented Jan 9, 2019

It seems like we need a definition

broadcastable(x::Enum) = Ref(x)

like the ones here.

Pointed out recently on discourse.

This won't break backwards compatibility, because currently broadcasting over an enum gives MethodError: no method matching length(::Foo).

@stevengj stevengj added good first issue Indicates a good issue for first-time contributors to Julia broadcast Applying a function over a collection labels Jan 9, 2019
@AzamatB
Copy link
Contributor

AzamatB commented Jan 11, 2019

Was fixed by #30675, so close this?

@pjgorski
Copy link

In Julia LTS this error still exists:

Example:

@enum E x = 0 y = 1
Es = [E(0) for i in 1:100]
Es .== E(0)

@stevengj
Copy link
Member Author

This feature requires Julia 1.2 or later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
broadcast Applying a function over a collection good first issue Indicates a good issue for first-time contributors to Julia
Projects
None yet
Development

No branches or pull requests

4 participants