Yes! but if I use block then any chance to control the same. as an
example I said here last. It can be any specific number. But yes
obviously when using with block.
Other than get the last combination, what is it you actually want to
do? What is the application?
Okay! I want to write a one liner which can give me the below output:
which is currently I am not able by the below block code with
combination,as in the below block I couldn’t track the,say,when second
‘arr’ is coming just print it,but not the others.:
Here,say I want to see the output only(without any fancy I write it
here,just to get to see the trick):
[1, 3, 5] #~~ means 5th combination
[2, 3, 5] #~~ means 8th combination
But yes only with block. Hope it is now clear to you @tamouse. My last
reply went to you by mistake without the output being written by me. I
tried to edit,but it passed then 15 mins,thus couldn’t.
Is thissupposed to be a general algorithm, say out of any combination,
you
will want the n-th combination? Or is there some scheme you have in mind
to
choose which combinations you are seeking?
Why does it have to be passed to a block from combination?
Generally, what is the problem you are trying to solve with this?
the combination array can be enormous …
thats why find.with_index can be better than to_a
My question was intended for “Love U Ruby”.
What the better solution is depends solely on the actual use
case, which the OP did not provide, even after the an explicit
inquiry by Tamouse. I do not want to speculate about this.
I strongly assume he himself does not know what kind of solution he
really needs.
Why???
What are you trying to do?
Why do you insist on using a block?
What is your use case?
We can give better advice when you tell us what you are trying
to accomplish. Using a block might not be the most effective solution.
what I was looking for is already given by - “Hans M.”.
So thanks for your curiosity. Please don’t curse always,no need to stick
on the topic that “I am trolling”. If you really like to help,you can,
But honest request don’t be off-topic.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.