Parameter function with 2 possible types

I’d maybe consider using separate overloads:

def testy(var : String)
  puts var
end

def testy(var : Array(String))
  var.each do |entry|
    puts entry
  end
end

Be a bit cleaner without the conditional logic

4 Likes