Created
August 11, 2013 22:00
-
-
Save scottmascio2115/6207057 to your computer and use it in GitHub Desktop.
abstract_data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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