in reply to variable name

What do you mean by "take 'var_for_this'" ?

Update: feel free to post the equivalent ruby code if you can't explain in english

The name of the variable you're using is normally known to you, since that's what you're writing. i.e. why would you want to do $name = name_of_var($var_for_this) when you can also write $name = '$name_of_var'?

Replies are listed 'Best First'.
Re^2: variable name
by sh1tn (Priest) on Jul 23, 2006 at 11:47 UTC
    var_name_for_this = :someSymbol print var_name_for_this.id2name
    this is from Ruby world


      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 ++ :)