mercredi 11 novembre 2015

Review for ruby "if" statement

do you have any suggestions for making this if condition shorter (more elegant) somehow?

if (@path.start_with? "scp" || @path.start_with? "http")
  @source = "url"
else
  @source = "local"
end

What if I have few more prefix to check (let's say ftp1, ftp2, and ftp3)?

Aucun commentaire:

Enregistrer un commentaire