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
class Test | |
def_p say_hello | |
puts "I'm a private method" | |
end | |
end |
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
class Test | |
def method_a | |
method_b | |
end | |
#just another public method. We might have several | |
def method_c | |
method_b | |
end | |
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
class Test | |
def method_a | |
method_b | |
end | |
def method_b | |
puts "I'm a private method" | |
end | |
private :method_b | |
end |
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
# this is the first way to do it | |
class Test | |
def say_hello | |
puts "I'm a private method" | |
end | |
private :say_hello | |
end | |
# and this is the second way | |
class Test |
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
[myArray each: ^(id *item){ | |
NSLog(@"Current item: %@", item); | |
}]; |
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
//in the interface file | |
@interface NSArray (each) | |
-(void) each: (void (^)(id *))block; | |
@end | |
//in the implementation file | |
@implementation NSArray (each) | |
-(void) each: (void (^)(id *))block { | |
for (id *object in self) { |
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
my_array.each do |item| | |
puts(item) | |
end |
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
// in the interface file | |
@interface Person : NSObject | |
{ | |
NSString *name; | |
} | |
@property(retain) NSString *name; | |
@end | |
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
class Person | |
attr_accessor :name | |
end |
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
class AppConstantsGenerator < Rails::Generators::Base | |
def self.source_root | |
@source_root ||= File.expand_path('../templates', __FILE__) | |
end | |
def copy_config_files | |
copy_file('constants.yml', 'config/constants.yml') | |
copy_file('load_app_constants.rb', 'config/initializers/load_app_constants.rb') | |
end | |
end |