This file contains hidden or 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
def hello name | |
"Hello #{name}" | |
end |
This file contains hidden or 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
puts( not(1 == 1) ) |
This file contains hidden or 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
puts( not( 1 == 1) ) |
This file contains hidden or 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
puts (not(1 == 1) ) |
This file contains hidden or 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
SyntaxError: compile error | |
(irb):1: syntax error, unexpected kNOT, expecting $end | |
puts not(1 == 1) | |
^ | |
from (irb):1 |
This file contains hidden or 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
>> puts (not(1 == 1)) | |
false | |
=> nil | |
>> puts( not(1 == 1)) |
This file contains hidden or 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
SyntaxError: compile error | |
(irb):3: syntax error, unexpected kNOT, expecting ')' | |
puts( not(1 == 1)) | |
^ | |
(irb):3: syntax error, unexpected ')', expecting $end | |
from (irb):3 |
This file contains hidden or 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 FileUtils | |
require 'fileutils' | |
FileUtils.mv 'test.txt', 'test1.txt' |
This file contains hidden or 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
=begin | |
doctest: leap_year? for 1900 and 1999 and 2001 is false | |
>> leap_year?(1900) | |
=> false | |
>> leap_year?(1999) | |
=> false | |
>> leap_year?(2001) | |
=> false | |
doctest: leap_year? for 1904, 1996 and 2000 are true |
This file contains hidden or 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
# a little program to accept a list of words, sort them without using the sort method, and output them in alphabetical order | |
i, j = 0, 0 # initialization of index variables | |
words, words2 = [], [] | |
a_word = 'a' # dummy initialization to get into the until loop below | |
puts "Type a word and press <Enter> (Enter a blank line to quit):" | |
# Loop to accept an unspecified number of words-- creates original array | |
until a_word.empty? | |
a_word = gets.chomp | |
unless a_word.empty? | |
words.push a_word |