Skip to content

Instantly share code, notes, and snippets.

View ahazem's full-sized avatar
🦊
I work for GitLab, so I'm rarely using this now. Please check my bio.

Ahmed Hemdan ahazem

🦊
I work for GitLab, so I'm rarely using this now. Please check my bio.
View GitHub Profile
@ahazem
ahazem / flatten.rb
Created January 15, 2016 10:40
A simple implementation of the flatten method
# Turn arbitrarily nested arrays into a flat one.
# Example: [[1,2,[3]],4] -> [1,2,3,4]
def flatten(array)
result = []
array.each do |element|
if element.is_a?(Array)
result.concat(flatten(element))
else

Keybase proof

I hereby claim:

  • I am ahazem on github.
  • I am ahazem (https://keybase.io/ahazem) on keybase.
  • I have a public key whose fingerprint is 5394 828C 52C5 2D71 4905 3731 FE83 02FC 1AA8 A0C7

To claim this, I am signing this object: