Search Options
close
Search the following clips:
All Clips
Everyone's Clips
My Guides
Sign Up
Install
Learn More
Login
Ruby Programming: String: puts and print
ciukes
follow
0
7-14-2008 7:57 AM
113 views
tags:
ruby
,
puts
,
print
Add a Comment
Login
to Comment. Not a member yet?
Sign up
Related Clips
Photos that Changed the World
There Is No Recession, There is No Recessi...
Photos by children on the theme "this is m...
The MOST HONEST Obituary You'll Ever See
Tutorial Index
Nineteen convictions and counting overturn...
Ruby Tuesday Blows Up
More clips from
ciukes
ActiveScaffold
Use a partial form with form_for
Ruby Programming: String: Single and doubl...
Today's Top Clips
"Artwork inspired by the mysteries and marvels of science." wonderful images
Brave New World of Digital Intimacy
Salvador Dali's Alice in Wonderland Series
Gait may be associated with orgasmic ability
24 of the most peculiar creatures known to mankind.
Physicists investigate how time moves forward
Palin by Andrew Sullivan
I can relate, but you don't want me as president
Alaska Police Union files complaint on Palin
Hey dude, i'm fighting a bacteria now
visit the
Top Clips page
View the Top Clips from
July 14, 2008
Embed This Clip In Your Site...
<div style="margin: 12px 0px; font-family: arial; color: #333333; background: #ffffff; border: solid 4px #e5e5e5; width: 100%; clear: left;"><div class="CM_CTB_Content_Wrap" style="margin: 0px; padding: 0px;background-color: #ffffff;"><div style="border-bottom: solid 1px #dcdcdc; white-space: nowrap; margin-bottom: 8px; background-color: #eeeeee ;background-image: url(http://clipmarks.com/images/source-bg.gif); background-repeat: repeat-x; height: 24px; line-height: 24px; vertical-align: middle; padding-bottom: 4px; color: #666666; font-size: 10px;" ><a href="http://clipmarks.com/clip-to-blog/" title="see clips that are hot right now"><img src="http://content.clipmarks.com/blog_embed/9480232a-357b-4b53-846b-513835f795ef/4541E17B-D976-4735-99A8-FB8F8A246B99/" alt="" width="19" height="19" border="0" style="vertical-align: middle; margin: 0px 4px; display: inline; border: none; float:none;" /></a>clipped from <a title="http://en.wikibooks.org/w/index.php?title=Ruby_Programming/Strings&oldid=1093022" href="http://en.wikibooks.org/w/index.php?title=Ruby_Programming/Strings&oldid=1093022" style="font-size: 11px;">en.wikibooks.org</a></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://en.wikibooks.org/w/index.php?title=Ruby_Programming/Strings&oldid=1093022"><H2><SPAN class="editsection">[<A title="Edit section: puts" href="http://en.wikibooks.org/w/index.php?title=Ruby_Programming/Strings&action=edit§ion=5">edit</A>]</SPAN> <SPAN class="mw-headline">puts</SPAN></H2></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://en.wikibooks.org/w/index.php?title=Ruby_Programming/Strings&oldid=1093022"><P>We've been using the <CODE>puts</CODE> function quite a bit to print out text. Whenever <CODE>puts</CODE> prints out text, it automatically prints out a newline after the text. For example, try the following code.</P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://en.wikibooks.org/w/index.php?title=Ruby_Programming/Strings&oldid=1093022"><PRE class="source-ruby"><SPAN class="kw3">puts</SPAN> <SPAN class="st0">"Say"</SPAN>, <SPAN class="st0">"hello"</SPAN>, <SPAN class="st0">"to"</SPAN>, <SPAN class="st0">"the"</SPAN>, <SPAN class="st0">"world"</SPAN> </PRE></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://en.wikibooks.org/w/index.php?title=Ruby_Programming/Strings&oldid=1093022"><P>The result:</P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://en.wikibooks.org/w/index.php?title=Ruby_Programming/Strings&oldid=1093022"><PRE>$ <B>hello-world.rb</B> Say hello to the world </PRE></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://en.wikibooks.org/w/index.php?title=Ruby_Programming/Strings&oldid=1093022"><H2><SPAN class="editsection">[<A title="Edit section: print" href="http://en.wikibooks.org/w/index.php?title=Ruby_Programming/Strings&action=edit§ion=6">edit</A>]</SPAN> <SPAN class="mw-headline">print</SPAN></H2></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://en.wikibooks.org/w/index.php?title=Ruby_Programming/Strings&oldid=1093022"><P>In contrast, Ruby's <CODE>print</CODE> function only prints out a newline if you specify one. For example, try out the following code. We include a newline at the end of <CODE>print</CODE>'s argument list so that the shell prompt appears on a new line, after the text.</P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://en.wikibooks.org/w/index.php?title=Ruby_Programming/Strings&oldid=1093022"><PRE class="source-ruby"><SPAN class="kw3">print</SPAN> <SPAN class="st0">"Say"</SPAN>, <SPAN class="st0">"hello"</SPAN>, <SPAN class="st0">"to"</SPAN>, <SPAN class="st0">"the"</SPAN>, <SPAN class="st0">"world"</SPAN>, <SPAN class="st0">"<SPAN class="es0">\n</SPAN>"</SPAN> </PRE></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://en.wikibooks.org/w/index.php?title=Ruby_Programming/Strings&oldid=1093022"><P>The result:</P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://en.wikibooks.org/w/index.php?title=Ruby_Programming/Strings&oldid=1093022"><PRE>$ <B>hello-world.rb</B> Sayhellototheworld </PRE></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://en.wikibooks.org/w/index.php?title=Ruby_Programming/Strings&oldid=1093022"><P>The following code produces the same output, with all the words run together.</P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://en.wikibooks.org/w/index.php?title=Ruby_Programming/Strings&oldid=1093022"><PRE class="source-ruby"><SPAN class="kw3">print</SPAN> <SPAN class="st0">"Say"</SPAN> <SPAN class="kw3">print</SPAN> <SPAN class="st0">"hello"</SPAN> <SPAN class="kw3">print</SPAN> <SPAN class="st0">"to"</SPAN> <SPAN class="kw3">print</SPAN> <SPAN class="st0">"the"</SPAN> <SPAN class="kw3">print</SPAN> <SPAN class="st0">"world"</SPAN> <SPAN class="kw3">print</SPAN> <SPAN class="st0">"<SPAN class="es0">\n</SPAN>"</SPAN> </PRE></blockquote></div><div style="margin: 0px 6px 6px 4px;"><table style="font-size: 11px;border-spacing: 0px;padding: 0px;" cellpadding="0" cellspacing="0" width="100%"><tr><td style="background:transparent;border-width:0px;padding:0px;"> </td><td align="right" style="background:transparent;border-width:0px;padding:0px;width:107px" width="107"><a href="http://clipmarks.com/share/4541E17B-D976-4735-99A8-FB8F8A246B99/blog/" title="blog or email this clip"><img src="http://content8.clipmarks.com/images/c2b-foot.png" border="0" alt="blog it" width="107" height="17" style="border-width:0px;padding:0px;margin:0px;" /></a></td></tr></table></div></div>
Clipmarks
Home
New Clips
Top Clips
Dashboard
Popular Topics
News
Life
Science
Technology
Entertainment
Get Started
Sign Up
Install Clipping Tool
How Clipping Works
Clip-to-Blog™
ClipSearch
Tools and Resources
FAQ
ClipWeek
Top Clippers
Top Tags
Site Map
About Clipmarks
About Us
Contact
Blog
Copyright
Privacy
EULA
OK