On Mon, Feb 18, 2013 at 8:38 PM, Love U Ruby wrote:
> @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)
> => #
On Mon, Feb 18, 2013 at 6:42 PM, Jack V. wrote:
> I would just create an array containing the parts you want to compare:
>
> objects.sort { |a,b| [a.lastname, a.firstname] <=> [b.lastname,
> b.firstname] }
In theory this is less efficient since there are two Array instances
created per compariso
On Mon, Feb 18, 2013 at 6:23 PM, Joel Pearson wrote:
> That Regexp to proc idea looks good. I could use proc form for a
> positive match and a normal block for the negative. I'll see if I can
> get something like this working when I write filter method for
> RubyExcel.
>
> Using the new class I ca
On Mon, Feb 18, 2013 at 5:39 PM, Robert Klemme
wrote:
> On Mon, Feb 18, 2013 at 5:19 PM, connor culleton wrote:
>> Then I am later including it in a controller class to get access to the
>> same methods. Including the whole thing again into another class feels
>> wrong some how...
>
> Why? That'
On Mon, Feb 18, 2013 at 5:19 PM, connor culleton wrote:
> Hey Robert!
>
> Yes you are correct. That was confusing terminology on my part, I am
> just using 'include' keyword. I'll edit the op now.
>
> "It will just insert the module in the inheritance chain (see
> MyController.ancestors) for
> met
On Mon, Feb 18, 2013 at 4:50 PM, Joel Pearson wrote:
> I went with "filter" with an optional true/false regex switch because it
> seemed like the simplest way to use it, and closest to my own experience
> in using Excel's filters.
> Passing the symbol feels less intuitive, and yielding to a block
On Mon, Feb 18, 2013 at 4:10 PM, connor culleton wrote:
> Hi Everyone,
>
> I am working with a test framework which has a module where a lot of
> functionally has been defined.
>
>
> module Stuff
> # lots_of_stuff...
> end
>
>
> When the test framework starts this module is loaded.
>
> I am c
On Mon, Feb 18, 2013 at 2:43 PM, Joel Pearson wrote:
> I do use switches occasionally, here's one example where I think it's
> justified (from my older Excel_Sheet
> def filter( header, regex, switch=true )
> fail ArgumentError, "#{regex} is not valid Regexp" unless regex.class
> == Regexp
>
On Mon, Feb 18, 2013 at 1:05 PM, Joel Pearson wrote:
> Nice tips! Thanks for the help again.
You're welcome.
> I had no idea how to use to_enum, I'll have to read up on that. I've
> done all the Ruby courses I could find at Codecademy which filled in a
> few gaps I had in my knowledge. I'm still
On Thu, Feb 14, 2013 at 9:31 PM, RKA wrote:
> Lambda functions are used when you want to call a function that doesn't
> necessarily need a name.
I would put it differently: lambdas are used when you need to use a
function as an object which can be referenced and passed around.
> For example, the
On Mon, Feb 18, 2013 at 12:42 AM, Dave Castellano wrote:
> Hi,
>
> As I continue learning to program, I am finding things I think can
> probably be
> done in a better way. The following code seems like something
> programmers must run into all the time and I am wondering if there is a
> better wa
11 matches
Mail list logo