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
string_1 = "Hello" | |
string_2 = "Hello" | |
puts "string_1's id is #{string_1.object_id}." | |
puts "string_2's id is #{string_2.object_id}." |
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
2.4.3 | |
Order of parameters and arguments | |
What output would you expect from this code snippet? | |
def mixed_args(a,b,*c,d) | |
puts "Arguments:" | |
puts a,b,c,d | |
end | |
mixed_args(1,2,3,4,5) | |
hatası da bu |
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
ef Ticket.most_expensive(*tickets) | |
tickets.max_by(&:price) | |
end | |
Now we can use the Ticket.most_expensive method to tell which of several tickets is | |
the most expensive. (We’ll avoid having two tickets with the same price, because our | |
method doesn’t deal gracefully with that situation.) | |
th = Ticket.new("Town Hall","11/12/13") | |
cc = Ticket.new("Convention Center","12/13/14/") | |
fg = Ticket.new("Fairgrounds", "13/14/15/") | |
th.price = 12.55 |
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
require "stacklike" | |
class Stack | |
include Stacklike | |
end | |
/home/fatih/Belgeler/RubyApplication1/lib/stack.rb:8: uninitialized constant Stack::Stacklike (NameError) |
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
# | |
# To change this template, choose Tools | Templates | |
# and open the template in the editor. | |
module StackLike | |
def stack | |
@stack ||= [] |
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
# | |
# To change this template, choose Tools | Templates | |
# and open the template in the editor. | |
require "stacklike" | |
class Suitcase | |
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
module Stacklike | |
def stack | |
@stack ||= [] | |
end | |
B | |
def add_to_stack(obj) | |
stack.push(obj) | |
end | |
def take_from_stack | |
stack.pop |
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
# | |
# To change this template, choose Tools | Templates | |
# and open the template in the editor. | |
module Stacklike | |
def stack | |
@stack ||= [] | |
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
NetBeansProjects/simple_cms$ rails g migration myMigration --trace | |
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:171:in `default_controller_and_action': missing :action (ArgumentError) | |
from /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:72:in `normalize_options!' | |
from /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:55:in `initialize' | |
from /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:272:in `new' | |
from /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:272:in `match' | |
from /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:1173:in `match' | |
from /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:1360:in `match' | |
from /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:259:in `r |
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
SimpleCms::Application.routes.draw do | |
resources :posts | |
root :controller => "posts" | |
# The priority is based upon order of creation: | |
# first created -> highest priority. | |
# Sample of regular route: | |
# match 'products/:id' => 'catalog#view' | |
# Keep in mind you can assign values other than :controller and :action |
OlderNewer