• Complain

Chahdi - Ruby Notes for Professionals: Ruby Programmation step by step

Here you can read online Chahdi - Ruby Notes for Professionals: Ruby Programmation step by step full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2021, publisher: UNKNOWN, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

No cover
  • Book:
    Ruby Notes for Professionals: Ruby Programmation step by step
  • Author:
  • Publisher:
    UNKNOWN
  • Genre:
  • Year:
    2021
  • Rating:
    5 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 100
    • 1
    • 2
    • 3
    • 4
    • 5

Ruby Notes for Professionals: Ruby Programmation step by step: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Ruby Notes for Professionals: Ruby Programmation step by step" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Chahdi: author's other books


Who wrote Ruby Notes for Professionals: Ruby Programmation step by step? Find out the surname, the name of the author of the book and a list of all author's works by series.

Ruby Notes for Professionals: Ruby Programmation step by step — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Ruby Notes for Professionals: Ruby Programmation step by step" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Contents
You may also like ...................................................................................................................................................... 226
About
Please feel free to share this PDF with anyone for free, latest version of this book can be downloaded from: https://goalkicker.com/RubyBook

This Ruby Notes for Professionals book is compiled from Stack Overflow Documentation , the content is written by the beautiful people at Stack Overflow. Text content is released under Creative Commons BY-SA, see credits at the end of this book whom contributed to the various chapters. Images may be copyright of their respective owners unless otherwise specified

This is an unofficial free book created for educational purposes and is not affiliated with official Ruby group(s) or company(s) nor Stack Overflow. All trademarks and registered trademarks are the property of their respective

company owners
The information presented in this book is not guaranteed to be correct nor accurate, use at your own risk
Please send feedback and corrections to web@petercv.com
Chapter 1: Getting started with Ruby Language

Version Release Date
2.5.1 2018-03-28
2.4 2016-12-25
2.3 2015-12-25
2.2 2014-12-25
2.1 2013-12-25
2.0 2013-02-24
1.9 2007-12-25
1.8 2003-08-04
1.6.8 2002-12-24

Section 1.1: Hello World
This example assumes Ruby is installed.
Place the following in a file named hello.rb :
puts 'Hello World'
From the command line, type the following command to execute the Ruby code from the source file:
$ ruby hello.rb
This should output:
Hello World
The output will be immediately displayed to the console. Ruby source files don't need to be compiled before being executed. The Ruby interpreter compiles and executes the Ruby file at runtime.
Section 1.2: Hello World as a Self-Executable Fileusing Shebang (Unix-like operating systems only)
You can add an interpreter directive (shebang) to your script. Create a file called hello_world.rb which contains:
#!/usr/bin/env ruby
puts 'Hello World!'
Give the script executable permissions. Here's how to do that in Unix:
$ chmod u+ x hello_world.rb
Now you do not need to call the Ruby interpreter explicitly to run your script. $ ./ hello_world.rb
Section 1.3: Hello World from IRB
Alternatively, you can use the Interactive Ruby Shell (IRB) to immediately execute the Ruby statements you previously wrote in the Ruby file.
Start an IRB session by typing:
$ irb
Then enter the following command:
puts "Hello World"
This results in the following console output (including newline):
Hello World
If you don't want to start a new line, you can use print :
print "Hello World"
Section 1.4: Hello World without source files
Run the command below in a shell after installing Ruby. This shows how you can execute simple Ruby programs without creating a Ruby file:
ruby - e 'puts "Hello World"'
You can also feed a Ruby program to the interpreter's standard input. One way to do that is to use a here document in your shell command:

ruby
END

Section 1.5: Hello World with tk
Tk is the standard graphical user interface (GUI) for Ruby. It provides a cross-platform GUI for Ruby programs.
Example code:

require "tk"
TkRoot.new { title "Hello World!" }
Tk.mainloop

The result:
Step by Step explanation require tk Load the tk package TkRootnew title - photo 1Step by Step explanation:
require
"tk"
Load the tk package.
TkRoot.new { title "Hello World!" }
Define a widget with the title Hello World
Tk.mainloop
Start the main loop and display the widget.
Section 1.6: My First Method
Overview
Create a new file named my_first_method.rb
Place the following code inside the file:

def hello_world
puts "Hello world!"
end

hello_world()# or just 'hello_world' (without parenthesis)
Now, from a command line, execute the following:
ruby my_first_method.rb
The output should be:
Hello world!
Explanation

def is a keyword that tells us that we're def -ining a method - in this case, hello_world is the name of our method.
puts "Hello world!" puts (or pipes to the console) the string Hello world!
end is a keyword that signifies we're ending our definition of the hello_world method as the hello_world method doesn't accept any arguments, you can omit the parenthesis by invoking the method

Chapter 2: Casting (type conversion)
Section 2.1: Casting to a Float
"123.50" .to_f #=> 123.5
Float ( "123.50" )#=> 123.5
However, there is a difference when the string is not a valid Float :
"something" .to_f #=> 0.0
Float ( "something" )# ArgumentError: invalid value for Float(): "something"
Section 2.2: Casting to a String
123.5 .to_s #=> "123.5"
String ( 123.5 )#=> "123.5"
Usually, String () will just call #to_s .
Methods Kernel#sprintf and String#% behave similar to C:

sprintf ( "%s" , 123.5 )#=> "123.5"
"%s" % 123.5 #=> "123.5"
"%d" % 123.5 #=> "123"
"%.2f" % 123.5 #=> "123.50"

Section 2.3: Casting to an Integer
"123.50" .to_i #=> 123
Integer ( "123.50" )#=> 123
A string will take the value of any integer at its start, but will not take integers from anywhere else:
"123-foo" .to_i # => 123
"foo-123" .to_i # => 0
However, there is a difference when the string is not a valid Integer:
"something" .to_i #=> 0
Integer ( "something" )# ArgumentError: invalid value for Integer(): "something"
Section 2.4: Floats and Integers
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Ruby Notes for Professionals: Ruby Programmation step by step»

Look at similar books to Ruby Notes for Professionals: Ruby Programmation step by step. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Ruby Notes for Professionals: Ruby Programmation step by step»

Discussion, reviews of the book Ruby Notes for Professionals: Ruby Programmation step by step and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.