Created
August 10, 2010 20:46
-
-
Save rishav/517976 to your computer and use it in GitHub Desktop.
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
| # Instance variables in models | |
| # recently i came across code where a friend of mine had written a lot code in models like its below ( without any attr_reader or accessor ) , is this ok or just plain useless, | |
| def coordinates | |
| @coordinates = [latitude, longitude] | |
| end | |
| # should we do something like below make more sense | |
| def coordinates | |
| @coordinates ||= [latitude, longitude] | |
| end | |
| # or just this is fine | |
| def coordinates | |
| [latitude, longitude] | |
| end | |
| # which one of them is better to use in rails, advantages or disadvantages | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment