Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #157

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Done #157

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .learn
100644 → 100755
Empty file.
Empty file modified .rspec
100644 → 100755
Empty file.
Empty file modified LICENSE.md
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
54 changes: 52 additions & 2 deletions programming_languages.rb
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,53 @@

#def reformat_languages(languages)
# new_hash = {}
# languages.each do |styles, langs|
# langs.each do |type, val|
# new_hash[type] ||= val
# new_hash[type][:style] ||= []
# new_hash[type][:style] << style
# end
# end
# new_hash
#end

#def reformat_languages(languages)
# new_hash = {}
# languages.each do |styles, langs|
# langs.each do |type, val|
# if new_hash.key?(type)
# new_hash[type][:style] << style
# else
# new_hash[type] = {:type => val.values[0], :style => [style]}
# end
# end
# end
#new_hash
#end

# I'm really having a hard time with this lab.
# I see there are two possible approaches to solving this lab. Both must account for
# "Javascript" having two styles. I adopted the code from other student labs to study
# while I develop a better understanding of these concepts.
# The top approach uses the "Or Equals" evaluation to
# construct the nested hashes, creating them if they are not already populated.
# The second method uses if/else logic to determine the same thing.
# In a third approach, the below method re-iterates over the hash to populate the
# :style symbol. I still do not quite understand the need for successive iterations or
# if/else logic here; I know the top method will not pass without the Or Equals evaluation...

def reformat_languages(languages)
# your code here
end
new_hash = {}
languages.each do |styles, langs|
langs.each do |type, val|
new_hash[type] = val
new_hash[type][:style] = []
end
end
languages.each do |styles, langs|
langs.each do |type, val|
new_hash[type][:style] << styles
end
end
return new_hash
end
Empty file modified spec/programming_languages_spec.rb
100644 → 100755
Empty file.
Empty file modified spec/spec_helper.rb
100644 → 100755
Empty file.