Welcome! This page is using CodeRay 1.1.2.

We currently have 2908 rays in the database.
You can add a New Ray or browse the posted rays by pages.

Page 3, 10 entries

a 38 lines of Ruby 794 Bytes Show Edit Expand
1
2
3
4
5
6
7
class Bicycle
  attr_reader :style, :size, :tape_color, :front_shock, :rear_shock

  def initialize(**opts)
    @style = opts[:style]
    @size = opts[:size]
    @tape_color = opts[:tape_colo...
a 10 lines of Ruby 231 Bytes Show Edit Expand
1
2
3
4
5
6
7
8
9
10
class Bicycle
  # ...
  def default_tire_size
    raise NotImplementedError,
          "#{self.class} should have implemented..."
  end
end

bent = RecumbentBike.new(size: "L")
# => Recumb...
a 9 lines of Ruby 176 Bytes Show Edit Expand
1
2
3
4
5
6
7
8
9
class Bicycle
  # ...
  def default_tire_size
    raise NotImplementedError
  end
end

bent = RecumbentBike.new(size: "L")
# => NotImplementedError: NotImplementedError
a 8 lines of Ruby 179 Bytes Show Edit Expand
1
2
3
4
5
6
7
8
class RecumbentBike < Bicycle
  def default_chain
    '10-speed'
  end
end

bent = RecumbentBike.new(size: "L")
# => undefined local variable or method 'default_tire_size' 
a 14 lines of Ruby 314 Bytes Show Edit Expand
1
2
3
4
5
6
7
8
9
10
road_bike = RoadBike.new(
  size: 'M',
  tape_color: 'red')

puts road_bike.tire_size # => 23
puts road_bike.chain # => 11-speed

mountain_bike = MountainBike.new(
  size: 'S',
  front_sho...
a 28 lines of Ruby 447 Bytes Show Edit Expand
1
2
3
4
5
6
7
class Bicycle
  attr_reader :size, :chain, :tire_size

  def initialize(**opts)
    @size = opts[:size]
    @chain = opts[:chain] || default_chain
    @tire_size = opts[:tire_size] || default...
a 1 line of Java 26 Bytes Show Edit Expand
1
System.out.print("Kurwa");
a 4 lines of Ruby 104 Bytes Show Edit Expand
1
2
3
4
puts road_bike.spares
# => {:chain => "11-speed",
#     :tire_size => "23",
#     :tape_color => nil}
a 2 lines of Ruby 72 Bytes Show Edit Expand
1
2
puts mountain_bike.spares
# => super: no superclass method 'spares' for
a 6 lines of Ruby 116 Bytes Show Edit Expand
1
2
3
4
5
6
class MountainBike < Bicycle
    # ...
    def spares
        super.merge(front_shock: front_shock)
    end
end

Page 3, 10 entries