Created
October 25, 2012 19:28
-
-
Save havenwood/3954864 to your computer and use it in GitHub Desktop.
Ruby Struct for Storing DNA
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
DNA = Struct.new(:name, :dna, :protein) | |
array = [] | |
array << DNA.new('H2', 'aaactg', 'IVL') | |
array << DNA.new('f9', 'ccctga', 'MET') | |
array[0].name | |
#=> "H2" | |
array[0].dna | |
#=> "aaactg" | |
array[1].protein | |
#=> "MET" | |
array.each do |dna| | |
puts "Name: #{dna.name} DNA: #{dna.dna} Protein: #{dna.protein}" | |
end | |
# Name: H2 DNA: aaactg Protein: IVL | |
# Name: f9 DNA: ccctga Protein: MET |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment