#ruby-lang - Tue 3 Apr 2007 between 07:33 and 07:38

NY Lost Funds



Xifzorglu_: you're passing it into an internal scope.
manveru:)
corundumreferences is http://crossproduct.net/~adam/objects.jpg
hrntzorglu_: after all, 5 is an instance of Fixnum.
apeiroszorglu_, check the link corundum gave
zorglu_ok i think the issue is the vocabulary :)
my definiition of passing by refernce is the one used in c/c++ world :)
ok will look
manjuwhich is the in thing GetOpt or optparse
hrntonly C++ has pass by reference
C is pass by value only
lypanovruby is pass by value but all values are pointers
hrntand ruby's references are not the same as C++s
zorglu_ahhhhhhhhh ok :)
actionlypanov aims to confuse lol
lypanovaims to confuse lol
apeiroszorglu_, also notice that assigning to a variable is NOT modifying the object
zorglu_apeiros: ah ok, bis :)
manveruit may sound complicated...
apeirosa = "hi"; b = a; a = "ho" # a and b point to a different object now
manverubut in fact it's pure zen :P
actionzorglu_ was considering that passing a pointer to an object is passing by reference :)
zorglu_was considering that passing a pointer to an object is passing by reference :)
apeiroshence: a == "ho" && b == "hi"
Xifzorglu_: yes, that's what I think too.
there's no copying of objects, hence it's pass by reference imho.
lypanovfrom perl perspective. yes
hrntin ruby a = "foo"; b = a; b = "bar"; a is "foo", b is "bar".
lypanovfrom c++ perspective, that means you can modify
zorglu_and if i a.sort_by! {|x| x }, do i assign a new object ? or changing the original ?
hrntin C++ std::string a("foo"); std::string &b = a; b = "bar"; // both a and b are "bar"
lypanovzorglu_: change the original
zorglu_ok thanks i got it a lot more now :)
and sorry for the original confusion
lypanovbut b = a.sort_by
is a copy
manverua = a.sort_by
zorglu_yep the ! stuff is like a special case
Xifit just depends on what the method does.
lypanovyeah
Xifthe bang method is just destructive (aka self-mutating)
manveruwatch out for mutants!

Page: 2 9 16 23 30 37 44 51 58 65 72 

IrcArchive

NY Lost Funds