Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
ruby-training
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Đường Sỹ Hoàng
ruby-training
Commits
18384cf5
Commit
18384cf5
authored
Nov 01, 2019
by
Đường Sỹ Hoàng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reading&Writng Files
parent
11c21369
Pipeline
#111
canceled with stages
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
3 deletions
+38
-3
exercise1.rb
+3
-3
exercise16.rb
+35
-0
No files found.
exercise1.rb
View file @
18384cf5
puts
"Hello World!"
#
print
"Hello World!"
puts
"Hello Again"
puts
"I like typing this."
puts
"This is fun"
puts
"Yay! Printing."
puts
"I'd much rather you 'not'."
puts
'I "said" do not touch this.'
\ No newline at end of file
puts
'I "said" do not touch this.'
exercise16.rb
0 → 100644
View file @
18384cf5
filename
=
ARGV
.
first
puts
"We're going to erase
#{
filename
}
"
puts
"If you don't want that, hit CTRL-C (^C)."
puts
"If you do want that, hit RETURN."
$stdin
.
gets
puts
"Opening the file..."
target
=
open
(
filename
,
'w'
)
puts
"Truncating the file. Goodbye!"
target
.
truncate
(
0
)
puts
"Now I'm going to ask you for three lines."
print
"line 1: "
line1
=
$stdin
.
gets
.
chomp
print
"line 2: "
line2
=
$stdin
.
gets
.
chomp
print
"line 3: "
line3
=
$stdin
.
gets
.
chomp
puts
"I'm going to write these to the file."
target
.
write
(
line1
)
target
.
write
(
"
\n
"
)
target
.
write
(
line2
)
target
.
write
(
"
\n
"
)
target
.
write
(
line3
)
target
.
write
(
"
\n
"
)
puts
"And finally, we close it."
target
.
close
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment