Class: Pippi::Checks::MapFollowedByFlatten::Documentation

Inherits:
Object
  • Object
show all
Defined in:
lib/pippi/checks/map_followed_by_flatten.rb

Instance Method Summary collapse

Instance Method Details

#descriptionObject



45
46
47
# File 'lib/pippi/checks/map_followed_by_flatten.rb', line 45

def description
  "Don't use map followed by flatten(1); use flat_map instead"
end

#instead_useObject



53
54
55
# File 'lib/pippi/checks/map_followed_by_flatten.rb', line 53

def instead_use
  '[1,2,3].flat_map {|x| [x, x+1]}'
end

#sampleObject



49
50
51
# File 'lib/pippi/checks/map_followed_by_flatten.rb', line 49

def sample
  '[1,2,3].map {|x| [x,x+1] }.flatten(1)'
end