Skip to content

Instantly share code, notes, and snippets.

@scottmascio2115
Created August 11, 2013 22:00
Show Gist options
  • Save scottmascio2115/6207057 to your computer and use it in GitHub Desktop.
Save scottmascio2115/6207057 to your computer and use it in GitHub Desktop.
abstract_data
# 1. Describe
# Contianer- A container is is simply a place to contain a collection of other objects
# They are used for storing objects in a specific way under set rules.
# ------------
# 2. Implement a container with all even numbers from 1..100
def container(array)
ray = Array.new
array.each do |x|
if x % 2 == 0
ray << x
end
end
print ray
end
puts container(1..100)
# ------------
# 3. Get real
# A container could be used to solve a real world problem if you needed to stored a
# set of data and arrange them that data. If you had a bunch of change, pennies,
# quarters, dimes and nickels a container could hold only quarters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment