Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7514615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:33:02+00:00 2026-05-30T00:33:02+00:00

This is just a quick Question. I am writing a feature here that creates

  • 0

This is just a quick Question. I am writing a feature here that creates a hash that has the Developer name as key and amount of points he scores for each feature he completed summed together. but we do have lazy Developers that don’t assign themselves to a task and thus we get hashes with nil as a key and i get NoMethodError: undefined method `name’ for nil:NilClass. what would be a clean way of ignoring nil?? here is my code

feat_hash = {}
features.group_by {|dev| dev.developer.name}.each {|dev_id, feat| feat_hash[dev_id] = feat.inject(0){|sum, x| sum + x.points}}

thanks in advance! 😀

EDIT: cool so this is the output that i get when i run it. you will notice it renders through the sprints that have the features that are assigned and those that are empty but as soon as it gets into a hash with a unassigned feature with nil as key it bugs out.

         _________features___________
{"Gary"=>13, "Rob"=>8, "Hannes"=>8, "Sandra"=>1}
      ___________bugs_____________
{}
      __________chores____________ 
{}
*************** New Sprint ************************
     _________features___________ 
{}
     ___________bugs_____________
{}
     __________chores____________
{}
*************** New Sprint ************************
     _________features___________
{}
     ___________bugs_____________
{}
     __________chores____________
{}
*************** New Sprint ************************
 NoMethodError: undefined method `name' for nil:NilClass

and then the rest of the error stack

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:33:03+00:00Added an answer on May 30, 2026 at 12:33 am

    You have this error because in the instruction dev.developer.name, dev.developer is nil. You can ignore these devs before the group_by

    features.reject {|dev| dev.developer.nil?}.group_by {|dev| dev.developer.name}.each { ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey just a quick question for anyone who has done this. I want to
This is just a quick question to understand correctly what happens when you create
This is just a quick question in C#. I have a scenario where I
Just a quick question about how you would go about implementing this. I want
I was just writing some quick code and noticed this complier error Using the
just a quick question. I've got this table in a Word template which have
Just a quick question on the iphone technology within this business card reader http://www.youtube.com/watch?v=F8z6pcxdrPo
Just a quick question about a function like this: class Test { public: Test(vector<int>&
Just a quick question about my Domain Layer/ Domain Service... Should I allow this
Just a quick question about the above subject. Basically, I'm writing a piece of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.