I am evaluating for the software I am working on a simple scripting language. I’ve mapped out what I need for Python but just trying Ruby since it was recommended to me as a simple language. Some of my users will not be programmers
I am trying to capture the matched variable in this any? method
I assign “match” to x and it will capture the variable. does anyone know if this is possible and if so, how to do it?
add = [1, 2, 3, 4]
if add.any?{|x| x == 1}
puts x
end
I can do it in python like this:
if any((match := x) == 1 for x in add):
print("x")
thanks for your help!