Created
September 9, 2014 21:36
-
-
Save petrokoriakin/ab4edd02c76fb7543c05 to your computer and use it in GitHub Desktop.
This file contains 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
proc and lambda? | |
yield | |
1. your own class as a key in hesh. listen carefully. | |
2. send(:momom) | |
3. | |
See http://ruby-doc.org/core/classes/Hash.html | |
Hash uses key.eql? to test keys for equality. If you need to use instances of your own classes as keys in a Hash, it is recommended that you define both the eql? and hash methods. The hash method must have the property that a.eql?(b) implies a.hash == b.hash. | |
The eql? method is easy to implement: return true if all member variables are the same. For the hash method, use [@data1, @data2].hash as Marc-Andre suggests in the comments. | |
Add a method called 'hash' to your class: | |
class Foo | |
def hash | |
return whatever_munge_of_instance_variables_you_like | |
end | |
end | |
This will work the way you requested and won't generate different hash keys for different, but identical, objects. | |
class Ololo | |
def boo | |
'boo'+object_id | |
end | |
def to_s | |
boo | |
end | |
end | |
a = Ololo.new | |
b = Ololo.new | |
{a => 'aaa', b => 'bbb'} | |
2. what is mvc. | |
3. what is bundler? | |
4. what type of active_record callbacks do you know. | |
after, before and arround. | |
5. repeateble code of actions. What to do with this code? | |
6. How to internationalize a rails app? | |
7. How to respond to the user :with :json :xml or :js | |
8. habtm vs. has_many :through | |
not enough! We do not need a Model | |
9. how to create RESTfull resource in Rails? | |
fignya v otvete | |
10. naming conventions User -> users table | |
ORM snova fignya. | |
11. What is default actions. | |
12. Default join. | |
left outer join is default. | |
12.2 What kind of join do you know | |
no answer | |
13 Some code. I need a code | |
14 | |
resources :users do | |
collection do | |
get :photos | |
end | |
member do | |
get :account | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment