def sayHi "hi!" end def listFiles( dir ) `ls #{dir}` end def getTime( format = "%a %b %d %H:%M:%S %Z %Y" ) Time.now.strftime( format ) end def printStuff( first, *args ) "#{first}, #{args.join(', ')}" end # calling a method without parameters puts sayHi # parens are optional puts sayHi() # calling a method with a parameter puts listFiles( "/" ) puts listFiles "/usr" # parens are also optional with parameters # calling a method with optional paramters puts getTime # optional parameters can be excluded puts getTime( "%m/%d/%Y %I:%M%p" ) # calling a method with variable length params puts printStuff(1, "two", 3, "four", 5, "six", 7) puts printStuff(*(1..10).to_a)