Last active
August 29, 2015 14:11
-
-
Save nelantone/01215f5ca0440b29d02c to your computer and use it in GitHub Desktop.
Done!
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
a = 5 | |
a_arry = [1,2,3,4,5] | |
b = 5.0 | |
b_arry = [1.0, 2.0, 3.0, 4.0, 5.0] | |
c = 'Stephan' | |
c_arry = %w(Stephan Beatrix Antonio Eugen) | |
## | |
def statistic(*extra) | |
if extra.empty? | |
return "empty arguments" | |
else | |
extra.each do |i| | |
if i.class == Array | |
puts "Class: #{i.class}" | |
puts "Size: #{i.size}" | |
puts "\nSTART - Array - START" | |
i.each do |j| | |
print_info(j) | |
end | |
puts "END - Array - END \n" | |
else | |
print_info(i) | |
end | |
end | |
end | |
return | |
end | |
def print_info(info) | |
puts "" | |
puts "Class : #{info.class}" | |
puts "Size : #{info.to_s.size}" | |
puts "Content : #{info}" | |
end | |
## OLD CODE | |
# def statistics(*extra) | |
# if extra.empty? | |
# return "empty arguments" | |
# elsif extra[0].class == Float | |
# extra.each do |i| | |
# puts "Class : #{i.class}" | |
# puts "Size : #{i.inspect.size - 2}" | |
# puts "Content : #{i}" | |
# end | |
# elsif extra.first.class == Array | |
# puts "Class : #{extra.class}" | |
# extra.each do |i| | |
# puts "Size : #{i.size}" | |
# puts "START - Array - START" | |
# i.each do |node| | |
# if node.class == Float or Fixnum | |
# puts "" | |
# puts "Class : #{node.class}" | |
# puts "Size : #{node.inspect.size}" | |
# puts "Content : #{node}" | |
# elsif node.class == String | |
# puts "" | |
# puts "Class : #{node.class}" | |
# puts "Size : #{node.size}" | |
# puts "Content : #{node}" | |
# end | |
# end | |
# end | |
# puts "END - ARRAY END" | |
# elsif extra.size == 1 | |
# extra.each do |i| | |
# puts "Class : #{i.class}" | |
# puts "Size : #{i.inspect.size}" # check size if it works, and put together no arryas as on top | |
# puts "Content : #{i}" | |
# end | |
# else #I think this is the error! give an elsif excepction (class and/or size) | |
# extra.each do |h, j| | |
# puts "Class : #{h.class}" | |
# puts "Size : #{h.inspect.size}" | |
# puts "Content : #{h}" | |
# puts "" | |
# end | |
# return | |
# end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment