Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Ruby Operators and Control Structures Logical Operators Practice time! Operators and Control Structures

Why do we call the functions at the bottom of the program rather than in between each function?

def get_name()        #gets a variable that is a name

  print "Enter your name: "


  return gets.chomp
  end
 name= get_name()  #your calling the function but unless you set it equal to name, it won't be able to be stored for furthur use letter in other functions. 


def greet(name)
 puts "Hi, #{name}!"
  if (name== "Nathan")
    puts "That's a great name!"
    end
  end
  greet(name)

def get_number()
  print "What number would you like to test?"
  return gets.chomp.to_i
  end
number= get_number()

def divisible_by_3?(number)
  return (number%3==0)
  end

      #functions called in correct order



if divisible_by_3?(number)

  puts "Your number is divisible by 3"
  else
  puts "Your number is not cleanly divisible by 3"
  end

as opposed to

name= get_name()       #functions called in correct order
  greet(name)
number= get_number()