Vibescript Showcase
Word and symbol arrays
Build string and symbol arrays with %w, %i, and their interpolating %W and %I companions.
Source
showcase/strings/word_arrays.vibe
# title: Word and symbol arrays
# category: Vibescript Showcase
# difficulty: Showcase
# summary: Build string and symbol arrays with %w, %i, and their interpolating %W and %I companions.
# description: Percent-literal arrays keep lists of tags, flags, and states terse; the uppercase forms interpolate so environment-specific lists stay a one-liner.
# tags: strings, symbols, literals
# vibe: 0.4
def static_tags
%w[alpha beta gamma]
end
def build_targets(env: string)
%W[build-#{env} deploy-#{env} verify-#{env}]
end
def lifecycle_states
%i[queued running done]
end
def run
{
static_tags: static_tags,
build_targets: build_targets("prod"),
lifecycle_states: lifecycle_states.map { |state| state.to_s },
first_state: lifecycle_states[0].to_s,
target_count: build_targets("staging").length
}
end
Output
Press run to execute run from this example.