Groovy: color selector
examples/groovy/color_selector.groovy
colors = ['Blue', 'Yellow', 'Brown', 'White'] println 'Please select a number:' colors.eachWithIndex { name, i -> println "${i}) ${name}" } def selection = System.in.newReader().readLine() as Integer if (selection < colors.size()) { println colors[selection] } else { println "Bad Selection" }
Published on 2018-06-02
If you have any comments or questions, feel free to post them on the source of this page in GitHub. Source on GitHub.
Comment on this post