Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.

 Ruby

You gonna love it.

Avatar for arpit shah

arpit shah

March 06, 2012
Tweet

Other Decks in Programming

Transcript

  1. Ruby A language that makes programmer programmer Ruby A language

    that makes programmer happy. programmer happy.
  2. DIT’.count(‘D') = Array.new = Array.new class Integer def even? (self

    % 2) == end end end (1..10).select { | # => [2, 4, 6, 8, 10] ) == 0 { |n| n.even? } => [2, 4, 6, 8, 10]
  3. ‘stressed’.reverse Food = [‘maggi', ‘chocolate ‘stressed’.reverse # desserts each {

    |food| print # Maggi Chocolate Ice reverse chocolate', ‘ice-cream'] reverse # desserts print( food.capitalize ) } # Maggi Chocolate Ice-cream
  4. get "/" do @articles = Article haml :index, :layout =>

    : haml :index, :layout => : end get "/articles/:id" do @article = Article haml :show, :layout => : end end Article.all :layout => :blogue :layout => :blogue do Article.get(params[:id]) :layout => :blogue
  5. class DoNothing class DoNothing { public static void main(String[] {

    // This program do nothing. } } } static void main(String[] args) // This program do nothing.
  6. class HelloWorldApp { public static void main(String[] System.out.println("Hello W }

    } public static void main(String[] args) { lo World!"); // Display the string.
  7. Class Circle private Coordinate center, float radius public void setCenter(Coordinate

    center){ this.center = center; this.center = center; } public Coordinate getCenter(){ return center; } public void setRadius(float radius){ this.radius = radius; } } public Coordinate getRadius(){ return radius; } } Coordinate center, float radius; (Coordinate center){
  8. module Logging def logger @logger ||= Logger end End End

    class Person include Logging def relocate logger.debug "Relocating person..." # do relocation stuff logger.debug "Relocating person..." # do relocation stuff end end Logger.new(opts) "Relocating person..." do relocation stuff "Relocating person..." do relocation stuff
  9. Ruby is designed to make programmers Ruby is designed to

    make programmers happy. - Matz - Matz