@ubuntu:~$ irb --simple-prompt >> class Foo >> def initialize(x,y,z) >> @x, @y, @z= x, y,z >> end >> def to_ary >> [@x, @y, @z] >> end >> def to_hash >> [@x => @y] >> end >> end => nil >> foo = Foo.new(10,11,12) => #<Foo:0x00000001191738 @x=10, @y=11, @z=12> My Question is with the below : >> a,*b = foo => #<Foo:0x00000001191738 @x=10, @y=11, @z=12> >> a => 10 >> b => [11, 12] How or which internal method has been called to make such assignment to a,*b from instance variables? Thanks
on 2013-02-18 20:37
on 2013-02-18 23:10
On Mon, Feb 18, 2013 at 8:38 PM, Love U Ruby <lists@ruby-forum.com> wrote: >>> end > => 10 >>> b > => [11, 12] > > How or which internal method has been called to make such assignment to > a,*b from instance variables? set_trace_func lambda {|*x| p x} and investigate yourself. Cheers robert
on 2013-02-19 07:59
Now I have tried the below : C:\>irb --simple-prompt >> class Foo >> def initialize(x,y,z) >> @x, @y, @z= x, y,z >> end >> def to_hash >> [@x => @y] >> end >> end => nil >> foo=Foo.new(10,11,12) => #<Foo:0x11f8968 @x=10, @y=11, @z=12> >> a,*b=foo => #<Foo:0x11f8968 @x=10, @y=11, @z=12> >> a => #<Foo:0x11f8968 @x=10, @y=11, @z=12> >> b => [] >> Here the results are not same as with the above. So is it calling my first instance method automatically? Couldn't understand the logic.
on 2013-02-19 08:26
Love U Ruby wrote in post #1097729: > Now I have tried the below : > > > C:\>irb --simple-prompt >>> class Foo >>> def initialize(x,y,z) >>> @x, @y, @z= x, y,z >>> end >>> def to_hash >>> [@x => @y] >>> end >>> end > => nil >>> foo=Foo.new(10,11,12) > => #<Foo:0x11f8968 @x=10, @y=11, @z=12> >>> a,*b=foo > => #<Foo:0x11f8968 @x=10, @y=11, @z=12> >>> a > => #<Foo:0x11f8968 @x=10, @y=11, @z=12> >>> b > => [] >>> > > Here the results are not same as with the above. So is it calling my > first instance method automatically? Couldn't understand the logic. WHY do you think that? why you dont get the IDEA that it MAYBE calls to_ary? becaue *arg is the Splat Operator that parts Arrays into members, and MAYBE it calls to_ary is the object is not an Array?
on 2013-02-19 10:08
Ok, understood what the guy wants ...
"Love U Ruby" is a troll trying to steal time.
See his other "posts".
If his original question would have been solely
about * then he would not have had the need to
write such awful code to pseudo-legitimize his
question.
I mean, he *must* know ruby because he purposely
returns an Array, and calls the method to_hash:
def to_hash
[@x => @y]
end
WTF?!?!
To the guy behind "Love U Ruby", please - go grow
up, find a job, then you won't have a need to go
trolling for reactions.
on 2013-02-19 15:46
Marc Heiler wrote in post #1097736: > Ok, understood what the guy wants ... > > "Love U Ruby" is a troll trying to steal time. > See his other "posts". Really never thought about to "steal" your time, no intention of that. I just asked you guys as you are expert. Just give me a tips or trick ... That's enough, I will dig into that. Please don't tell that way;You are educated on this, thus asked. And another person also trying to be fit on your domain, Is it bad? You should be proud by thinking that - what you love,others too. If anyone incomplete, please try or at-least give him/her something so that he can be strong. We should share our knowledge - that's why the forum built,to keep you and like me, or you like you people come close and help each other. > I mean, he *must* know ruby because he purposely > returns an Array, and calls the method to_hash: > > def to_hash > [@x => @y] > end > > WTF?!?! > > To the guy behind "Love U Ruby", please - go grow > up, find a job, then you won't have a need to go > trolling for reactions.
on 2013-02-19 16:09
On Tue, Feb 19, 2013 at 3:46 PM, Love U Ruby <lists@ruby-forum.com> wrote: > Marc Heiler wrote in post #1097736: >> Ok, understood what the guy wants ... >> >> "Love U Ruby" is a troll trying to steal time. >> See his other "posts". > > Really never thought about to "steal" your time, no intention of that. I > just asked you guys as you are expert. Just give me a tips or trick ... Then why do you not work with the replies you get? > We should share our knowledge - that's why the forum built,to keep you > and like me, or you like you people come close and help each other. Sharing is OK - spoonfeeding is not. Cheers robert
on 2013-02-19 20:34
On Feb 19, 2013, at 6:46, Love U Ruby <lists@ruby-forum.com> wrote: > Really never thought about to "steal" your time, no intention of that. I > just asked you guys as you are expert. Just give me a tips or trick ... > That's enough, I will dig into that. Please don't tell that way;You are > educated on this, thus asked. And another person also trying to be fit > on your domain, Is it bad? Yes, the way you do it IS bad. You are a help vampire: http://slash7.com/2006/12/22/vampires/ As described below, you are a "leech" help vampire: http://jasonwryan.com/blog/2012/03/17/vampires/ As I've said before, mend your ways.
on 2013-02-19 21:35
Ryan Davis wrote in post #1097840: > On Feb 19, 2013, at 6:46, Love U Ruby <lists@ruby-forum.com> wrote: > >> Really never thought about to "steal" your time, no intention of that. I >> just asked you guys as you are expert. Just give me a tips or trick ... >> That's enough, I will dig into that. Please don't tell that way;You are >> educated on this, thus asked. And another person also trying to be fit >> on your domain, Is it bad? > > Yes, the way you do it IS bad. You are a help vampire: > > http://slash7.com/2006/12/22/vampires/ > > As described below, you are a "leech" help vampire: > > http://jasonwryan.com/blog/2012/03/17/vampires/ > > As I've said before, mend your ways. It's all about the perception... depends on people mentality. Forum is to help someone. I would agree with Robert, although not with you. You people have time to browse through these links but when someone would ask something - you are saying "NOT TO WASTE YOUR TIME". you know my name.. right? so any post with my name please ignore.. Please don't spread such bad things over all. Remember you also passed such days when you were junior to ruby...
on 2013-02-19 22:15
On 19 February 2013 20:35, Love U Ruby <lists@ruby-forum.com> wrote:
> Forum is to help someone.
Firstly this is not a forum but a mailing list.
Second we do not come here to help people, we come here because we are
members of a community. We help people because we feel like it not
because
we have a duty to.
You are right about one thing though, it is all about perception. Why do
you think people call you help vampire?
on 2013-02-19 22:22
Peter Hickman wrote in post #1097848: > On 19 February 2013 20:35, Love U Ruby <lists@ruby-forum.com> wrote: > >> Forum is to help someone. > > > Firstly this is not a forum but a mailing list. > Second we do not come here to help people, we come here because we are > members of a community. We help people because we feel like it not > because > we have a duty to. > > You are right about one thing though, it is all about perception. Why do > you think people call you help vampire? Leave it. Answering such cheap things seems to me really time wastage. "And be remember - a just brown tree welcomes people who are giving water at it's root, but never disrespect who are not." ~~~ First time I am seeing this community such bad mentalities of people. It seems I am asking money from their accounts. I am asking to share their tips if any, but ........ have no words. Thanks
on 2013-02-19 22:38
On 19 February 2013 21:22, Love U Ruby <lists@ruby-forum.com> wrote: > ~~~ First time I am seeing this community such bad mentalities of > people. It seems I am asking money from their accounts. I am asking to > share their tips if any, but ........ have no words. > > You are asking for their time which is a commodity that can never be got back. If I spend money I can just earn some more, the time I spend here is lost when it passes. I commute 5 hours a day, I work 8 hours a day, I sleep 7 hours a day. Do the maths Just replying to this post will take around 10 to 15 minutes as I stop, rewrite, reedit, reread repeatedly. Just because we give freely does not mean it is worthless and it is certainly not cheap.
on 2013-02-19 22:46
Always interesting when people bring out the proverbs On Tue, Feb 19, 2013 at 1:22 PM, Love U Ruby <lists@ruby-forum.com> wrote: > Leave it. Answering such cheap things seems to me really time wastage. > "And be remember - a just brown tree welcomes people who are giving > water at it's root, but never disrespect who are not." > Are you sure you grasp which role you are in the proverb at the moment? The next paragraph would seem to indicate otherwise..... > ~~~ First time I am seeing this community such bad mentalities of > people. It seems I am asking money from their accounts. I am asking to > share their tips if any, but ........ have no words. > Not very respectful of those not "giving water". Going back to your question - shocking what the words "splat ruby" might bring someone as a first hit. John
on 2013-02-19 22:52
Peter Hickman wrote in post #1097851: > On 19 February 2013 21:22, Love U Ruby <lists@ruby-forum.com> wrote: > >> ~~~ First time I am seeing this community such bad mentalities of >> people. It seems I am asking money from their accounts. I am asking to >> share their tips if any, but ........ have no words. >> >> > > You are asking for their time which is a commodity that can never be got > back. If I spend money I can just earn some more, the time I spend here > is These all are vague. Then how should I call "Google" who keep sharing the knowledge to everyone "FREE", how would you consider "YouTube" who does the same job. How would you consider the the man : "David A. Black" writer of "The Well-Grounded Ruby". Go to the link: and see how is he redelivering all his speech what he already mentioned in his book and "YouTube" giving us it FREE : http://www.youtube.com/watch?v=Xt6c6r4fbBs So in simple sentence it is depends upon people mentality, who felt disturbed when he shouldn't but he can obviously. But in such a case don't need to be keep shouting. If you love to share knowledge share it,otherwise keep quite. Don't try to assemble a group of like you. Its not about help,not about money, only about dedications... then you don't have. --- Thanks
on 2013-02-19 22:55
John W Higgins wrote in post #1097852: > Always interesting when people bring out the proverbs > > On Tue, Feb 19, 2013 at 1:22 PM, Love U Ruby <lists@ruby-forum.com> > wrote: >> ~~~ First time I am seeing this community such bad mentalities of >> people. It seems I am asking money from their accounts. I am asking to >> share their tips if any, but ........ have no words. > Not very respectful of those not "giving water". Your catch is wrong, so I am helpless. > John
on 2013-02-19 23:12
On Tue, Feb 19, 2013 at 1:52 PM, Love U Ruby <lists@ruby-forum.com> wrote: > > Its not about help,not about money, only about dedications... then you > don't have. --- Thanks > Proverb time again apparently........... John
on 2013-02-19 23:25
This whole exchange reminds of this quote: I went to a bookstore and asked the saleswoman, "Where's the self-help section?" She said if she told me, it would defeat the purpose. Anyway, consider this line of reasoning: 1) Do not feed the trolls. 2) Goto 1
on 2013-02-19 23:25
On Tue, Feb 19, 2013 at 1:55 PM, Love U Ruby <lists@ruby-forum.com> wrote: > > > Not very respectful of those not "giving water". > > Your catch is wrong, so I am helpless. > > So you refuse to offer help and explain your great proverb to someone who might not understand the meaning of it? That surely wouldn't take place in your utopian view of this area would it? John
on 2013-02-19 23:35
On Tue, 19 Feb 2013 22:37:59 +0100, Peter Hickman <peterhickman386@googlemail.com> wrote: > Just replying to this post will take around 10 to 15 minutes as I stop, > rewrite, reedit, reread repeatedly. You could also finally shut up, as it wastes the time of every list subscriber to scan and delete your messages every day.
on 2013-02-20 00:07
On Feb 19, 2013, at 12:35 , Love U Ruby <lists@ruby-forum.com> wrote: >> > to help someone. I would agree with Robert, although not with you. It is about the perception of the group. Not the individual. The more you behave the way you do, the more the group will perceive you as a help vampire. Tho, after seeing the rest of your responses to this thread, the more you come off like a troll. Keep up the good work.
on 2013-02-20 10:28
On 19 February 2013 22:34, Bartosz Dziewoński <matma.rex@gmail.com> wrote: > You could also finally shut up, as it wastes the time of every list > subscriber to scan and delete your messages every day. > > Well you could always put my email address in the kill file for your news reader or if you use Gmail you could create a filter to delete all posts from my email address. Then you would never have to ever see them. I'm sure that such facilities exist in most software (unless you are reading this on a forum, in which case you will have to find out for yourself). If my posts were causing you such grief then surely you would have done this already. But then you would miss out on me giving you this useful advice :)
on 2013-02-20 13:45
hi all i am a follower i admire the great efforts finding solutions in Ruby we can watch experts unravel them here turning to others for help may lead to misunderstandings mentors freely maintain a valuable driving force in the forum this is a great forum for precise advice that makes a real difference i am a slow learner i study by repetition as if i am a bit thick in the head clearly wrath awaits aspirants who crib or skip any staple rules of Ruby spotting mistakes helps strive to learn more effectively much obliged to everyone and best wishes for all through the year timo On Wed, Feb 20, 2013 at 8:27 PM, Peter Hickman <
on 2013-02-24 17:24
when we write the "range" with splat(*) generally got the array as below: >> a = *(2..5) => [2, 3, 4, 5] But in the previous case why I got [2, 3, 4, 5] not [[2, 3, 4, 5]] >> a = [*(2..5)] => [2, 3, 4, 5] >> here and there concept in Ruby.... Huuhh ;-)
on 2013-02-25 00:30
On 25 February 2013 02:24, Love U Ruby <lists@ruby-forum.com> wrote: > > here and there concept in Ruby.... Huuhh ;-) This is a legitimate question. As we've seen, on the splitting side (i.e. the RHS of an assignment, if any) the splat operator attempts to convert an object into an array, pretty sure it does it by calling that object's to_a method. Thus the following would be functionally identical: a = *(2..5) a = (2..5).to_a However it does more than that. The splitting side of splat can splice the splatted value into an array, for example: a = [1, *(2..3), 4] # => a = [1,2,3,4] By paring that down and removing the 1 and 4, you can see why: a = [ *(2..3) ] # => a = [2,3] It splices the splatted range into the existing (anonymous) array. If you want it to be nested inside, you have to explicitly call `(2..3).to_a` instead.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.