Results 1 to 4 of 4

Thread: Ruby Function Syntax

  1. #1
    Join Date
    Apr 2009
    Posts
    87

    Ruby Function Syntax

    I know Ruby language makes easy to create functions to call method in program and also enable reuse of code across multiple programs. I need more information on ruby functions and some example which describe where to use that function.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Ruby Function Syntax

    Example of Ruby Function
    Code:
    def functionname(variable)
       return <value>
    end

    Your function can store this value and call this value to the function through variable which are declare. Those values can then be returned with the return statement.

  3. #3
    Join Date
    Jan 2009
    Posts
    199

    Re: Ruby Function Syntax

    Some methods defined in the Kernel module can be called from everywhere, and are to be called like functions. You'd better think twice before redefining these methods.The syntax of Ruby is broadly similar to Perl and Python. Class and method definitions are signaled by keywords. In contrast to Perl, variables are not obligatorily prefixed with a sigil. When used, the sigil changes the semantics of scope of the variable.

  4. #4
    Join Date
    Dec 2008
    Posts
    177

    Re: Ruby Function Syntax

    This Ruby Function Syntax Example will creates an unnecessary function.

    Code:
    def saybye(name)
      result = "bye, " + name
      return result
    end
     
    # Let's say bye
    puts saybye("Ruby")
    puts saybye("Syntax")
    Check this link for more information about ruby function : Ruby & Ruby on Rails programming tutorials

Similar Threads

  1. Syntax/Semantics for a C++ "Function Template"?
    By Juan-Carlos in forum Software Development
    Replies: 3
    Last Post: 11-11-2009, 06:44 PM
  2. help on pokemon ruby by using no$gba
    By a7medo in forum Video Games
    Replies: 1
    Last Post: 31-08-2009, 07:34 AM
  3. How to use Ruby application and benefits of ruby application
    By FlayoFish in forum Windows Software
    Replies: 3
    Last Post: 30-07-2009, 11:17 AM
  4. Ruby On Rails vs. ASP.Net
    By FlayoFish in forum Software Development
    Replies: 2
    Last Post: 17-04-2009, 03:18 PM
  5. Ruby - what is it
    By Cyclups in forum Software Development
    Replies: 10
    Last Post: 07-04-2009, 02:12 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,791,890.87539 seconds with 16 queries