#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    184
    Rep Power
    14

    Accessing object members with a symbol/string


    In php it is possible to access the members of an object through the use of a string.
    ex:

    PHP Code:
    $member 'name'
    $person = new Person'james' )
    echo 
    $person->$member 
    Would print james, making all the usual assumptions about the person class.

    Is there anything like this possible in ruby?
    --Tantapants
  2. #2
  3. fork while true;
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2005
    Location
    England, UK
    Posts
    5,538
    Rep Power
    1051
    Naturally

    object.send(name)

    Works for functions and variables.

IMN logo majestic logo threadwatch logo seochat tools logo