Recursion
Algorithms
Computability Theory
Logic
Theoretical Computer Science
Arrays
Data Types
Methods
Functions
Object-oriented Programming
Control Flow
Basic Language Features
Fundamentals
Programming Paradigms
Classes
class Array # Opens up the Array class for method creation def flip self.reverse.map{|e| e.is_a?(Array) ? e.flip : e} end end
- class Array # Opens up the Array class for method creation
- def flip
result = []me = self.reverse # Don't fret, I'll sort the Arrays out!me.each do |x|if x.class == Array then result << x.flip # Here's the recursion.else result << xendendreturn result- self.reverse.map{|e| e.is_a?(Array) ? e.flip : e}
- end
- end