Skip to content

Instantly share code, notes, and snippets.

@sandeep1988
Created February 20, 2020 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandeep1988/8b1a737a0e2a46e09a57ad70381ba5d4 to your computer and use it in GitHub Desktop.
Save sandeep1988/8b1a737a0e2a46e09a57ad70381ba5d4 to your computer and use it in GitHub Desktop.
assignment1
# Example 1:
def get_addresses
addresses = User.includes(:address)
end
======================
# Example 2:
Solution: We will call directly initialize method for getter and setter method.
class Greeting
def initialize(name)
@name = name
end
end
========================================
# Example 3:
Solutions:
def sum (*arr)
arr.inject(:+)
end
test case=> sum(1,2,3,4,4,4) => 18
test case=> sum(1,2) => 3
========================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment