mentby.com
Blog | Jobs | Help | Signup | Login

loading

Hash return is not correct

Mon, 06 May 2013 00:20:24 -0700 Post Comments

No the output is correct. Your mistake is assuming that Router.new will
return the same object for the same input parameters. For example:

frequency = Hash.new(0)
models = %w(2000 3000 2000 3200)
models.each{|m| frequency[Router.new('Linksys',m)] += 1}

p frequency => {

#<Router:0x10f80ae70 @model="3000", @make="Linksys">=>1,

#<Router:0x10f80ae20 @model="2000", @make="Linksys">=>1,

#<Router:0x10f80aec0 @model="2000", @make="Linksys">=>1,

#<Router:0x10f80add0 @model="3200", @make="Linksys">=>1

}

Note each entry is a different object. This is the normal and
correct behaviour. When you do:

puts frequency[Router.new('Linksys','2000')]

I assume you meant this and not Car.new it creates yet another object which
of course is not in the hash and so returns 0.

Does anyone who USES Rails hate Rails?

Wed, 01 May 2013 08:06:30 -0700 Post Comments

If you have ten years of C/C++ you don't have to apply for Rails jobs. Just
apply for C/C++ jobs and when they ask why you did Rails just tell them you
felt like a change but it didn't work out. Lets face it 10 years of C/C++
should be most impressive. But you will have to articulate your dislike of
Rails in a considerably more professional way than you are expressing it
here. To be honest you sound like a whiner. You didn't get on with Rails,
big deal. I didn't get on with Java despite doing it for a few years. I
just politely decline Java jobs and thank them for their interest.

Don't let it fester, it will eat you alive.

This is odd. Ruby is generally considerably easier than either Java or C++
because there are less things to actually do. In Ruby a class is a class,
in Java and C++ you have static classes, abstract classes so there are more
design decisions and the application source gets longer. In Ruby the
methods are either public, protected, private or class methods. Again less
decisions and less code to type.

Maybe dynamic languages are not your thing. Fine. No problem. Java is not
my thing but I'm ok with C and C++. People are different.

Ruby and Rails can indeed develop applications very quickly. But the code
on the whole is quite shallow and amenable to refactoring. You tell the
client that something can be put together very quickly but should they want
it extended in ways that were not part of the original design it could take
longer than they think. Perhaps the issue here is that you are trying to
apply BIG APPLICATION development practices from java and C++ in an
environment where Agile or XP would be better suited. It is not a
coincidence that the Ruby and Rails communities embraced Agile and XP, or
at least iterative development.

If I were to apply my mainframe COBOL or Fortran development practices to
our Rails applications it would indeed be a world of pain.

So what you are saying is that you can't stand the heat. Too much
competition and you have no way of showing how much better a programmer
than all these other guys who are actually interested in Rails.

The statement actually contradicts you earlier statement "To be honest many
things are significantly harder than java and c++" and the later statement
"The low entry breads lazy coders..  And they stay ignorant". How can it
lower the bar, which I assume you mean allows a lower quality of programmer
to take work from you, and be harder than Java and C++. Those are some shit
hot lazy bastards you got there. Send a few of them my way, my developers
have only one Phd between them :)

Well Java only sits on C so doesn't the same apply here?

At one point C++ was just a preprocessor that kicked out C code so that
puts C++ in the same category as Ruby then :)

You need to leave that job solely for the sake of you mental health.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe*******.
To post to this group, send email to rubyonrails-talk*******.
For more options, visit  https://groups.google.com/groups/opt_out.

New Rexx like data structure

Mon, 29 Apr 2013 08:09:09 -0700 Post Comments

This is just something that I have been playing with for some time but I
thought a structure like this might be cool.

a = Hash.new
a.b = 12

This behaves the same as a['b'] = 12, and this ...

a.c.d = 42

behaves like this ...

a['c']['d'] = 42

The syntax looks cleaner to me if a little Rexxish (or Lua like). Here's
how I implemented it

class Hash
  def method_missing(m, *args, &block)
    key = m.to_s

    if key =~ /(.*)=$/
      self.store($1, args.first)
    elsif self[key] == nil
      self.store(key, Hash.new)
    else
      self[key]
    end
  end
end

There is just one little wrinkle in this plan

a.j => Hash

Given that a.j has not beed defined, that is there has been no "a.j = 19"
for example, I would prefer that a.j return nil but can't for the life of
me think how to get this to work.

Any suggestions?

Read more »

Profile Widget
Copy and paste this HTML code to your blog or website: