-
-
Save sandeep1988/8b1a737a0e2a46e09a57ad70381ba5d4 to your computer and use it in GitHub Desktop.
assignment1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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