Problems understanding Ruby code -
i have code:
all_backups = dir.entries[2..-1].sort.reverse max_backups = 20 unwanted_backups = all_backups[max_backups..-1] || []
i think gets entries in defined folder. [2..-1]
? all_backups[max_backups..-1] || []
?
dir.entries[2..-1]
get elements index 2(means 3rd element of array) last index(last element of array). in ruby -1
means last element of array
instance.
all_backups[max_backups..-1] || []
all_backups[max_backups..-1]
gives nil
, assign empty array []
variables other wise returned array all_backups[max_backups..-1]
.
Comments
Post a Comment