From 764fff4b47b37d84f4850423c915f03438ff1078 Mon Sep 17 00:00:00 2001 From: KronosTheLate <61620837+KronosTheLate@users.noreply.github.com> Date: Mon, 6 Jun 2022 12:55:07 +0200 Subject: [PATCH] Add method for generator given to Select This PR adds a method for select for the first argument of type Generator. An example is added. The added method only sometimes played nice when default values were provided. In my testing, I was unable to figure out the reason. More testing should be done before this is merged to resolve the buggy behaviour when providing default values. I am not sure how extensive testing is for this package, but testing should be added as --- src/Builtins.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Builtins.jl b/src/Builtins.jl index 5344f538..61a7b900 100644 --- a/src/Builtins.jl +++ b/src/Builtins.jl @@ -598,6 +598,14 @@ begin f(0.5) ``` + + If a generator is given, it is automatically turned into a vector: + + ```julia + @bind f Select(i for i in 1:10) + # is equivalent to + @bind f Select([i for i in 1:10]) + ``` """ struct Select options::AbstractVector{Pair} @@ -609,6 +617,8 @@ begin Select(options::AbstractVector{<:Pair}; default=missing) = Select(options, default) + Select(options::Base.Generator; default=missing) = Select([options...]; default) + function Base.show(io::IO, m::MIME"text/html", select::Select)