in reply to Re: variable name
in thread variable name

var_name_for_this = :someSymbol print var_name_for_this.id2name
this is from Ruby world


Replies are listed 'Best First'.
Re^3: variable name
by Joost (Canon) on Jul 23, 2006 at 12:09 UTC
    sorry, but symbols have nothing to do with variables; they're just "fast strings".

    Perl doesnt have symbols (or at least, nothing like ruby's symbols), so the equivalent in perl would be something like

    $var_name_for_this = 'someSymbol';
    Note that there is no 'someSymbol' variable anywhere, but then, there isn't one in your ruby code either.

    update: to be clear, ruby's symbols (the :something construct) are NOT variables, they're values. For most purposes, ruby symbols act like strings with the advantage that you don't have to fully quote them - just a ":" at the beginning is enough:

    pair = { :name, value } # name quoted with :
    Note that perl has something similar when using the => 'quoting comma':
    $pair = { name => $value }; # name quoted with =>
      Thanks ++ :)