<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.1.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Bring your methods to life with punctuation</title>
	<link>http://www.rubyfleebie.com/bring-your-methods-to-life-with-punctuation/</link>
	<description>Because programming should be fun</description>
	<pubDate>Sat, 22 Nov 2008 07:01:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.2</generator>

	<item>
		<title>By: Peter</title>
		<link>http://www.rubyfleebie.com/bring-your-methods-to-life-with-punctuation/#comment-40</link>
		<author>Peter</author>
		<pubDate>Thu, 29 Mar 2007 20:40:13 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/bring-your-methods-to-life-with-punctuation/#comment-40</guid>
					<description>unless user logged_in? 

sounds pretty nice</description>
		<content:encoded><![CDATA[<p>unless user logged_in? </p>
<p>sounds pretty nice</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Jamal Soueidan</title>
		<link>http://www.rubyfleebie.com/bring-your-methods-to-life-with-punctuation/#comment-43</link>
		<author>Jamal Soueidan</author>
		<pubDate>Fri, 30 Mar 2007 23:51:27 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/bring-your-methods-to-life-with-punctuation/#comment-43</guid>
					<description>Thanks for that :)

So how do you do your own method like that?

For: ?
def method
 return true or false
end

if method? 
 #do that
end

For: !

def method
  raise "exception"
end

method!
rescue "exception"

or something like that?

Can you tell us how to use both ! or ? or nothing ?, a article/post about methods will be really great :D</description>
		<content:encoded><![CDATA[<p>Thanks for that <img src='http://www.rubyfleebie.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So how do you do your own method like that?</p>
<p>For: ?<br />
def method<br />
 return true or false<br />
end</p>
<p>if method?<br />
 #do that<br />
end</p>
<p>For: !</p>
<p>def method<br />
  raise &#8220;exception&#8221;<br />
end</p>
<p>method!<br />
rescue &#8220;exception&#8221;</p>
<p>or something like that?</p>
<p>Can you tell us how to use both ! or ? or nothing ?, a article/post about methods will be really great <img src='http://www.rubyfleebie.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /></p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Frank</title>
		<link>http://www.rubyfleebie.com/bring-your-methods-to-life-with-punctuation/#comment-46</link>
		<author>Frank</author>
		<pubDate>Sat, 31 Mar 2007 13:12:12 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/bring-your-methods-to-life-with-punctuation/#comment-46</guid>
					<description>Hey Jamal,

The "?" and "!" characters are not doing something special on their own. It's just that you can include them in the name of your methods if you want. It's only a convention to use the "?" character in methods that does nothing worth of mention other than returning yes or no. As it's just a convention to use the "!" character in methods that do something destructive or "dangerous". You could (but should not) use them for other purpose.

So, if you want to write : if my_method? ...

You would have to define it this way :

def my_method?
   return true #or false, or anything you want
end

If you want to write : destroy!

You would have to define it this way :

def destroy!
  #Do something destructive like deleting all rows of a table in a DB
end

I hope it does answer your question</description>
		<content:encoded><![CDATA[<p>Hey Jamal,</p>
<p>The &#8220;?&#8221; and &#8220;!&#8221; characters are not doing something special on their own. It&#8217;s just that you can include them in the name of your methods if you want. It&#8217;s only a convention to use the &#8220;?&#8221; character in methods that does nothing worth of mention other than returning yes or no. As it&#8217;s just a convention to use the &#8220;!&#8221; character in methods that do something destructive or &#8220;dangerous&#8221;. You could (but should not) use them for other purpose.</p>
<p>So, if you want to write : if my_method? &#8230;</p>
<p>You would have to define it this way :</p>
<p>def my_method?<br />
   return true #or false, or anything you want<br />
end</p>
<p>If you want to write : destroy!</p>
<p>You would have to define it this way :</p>
<p>def destroy!<br />
  #Do something destructive like deleting all rows of a table in a DB<br />
end</p>
<p>I hope it does answer your question</p>
]]></content:encoded>
				</item>
</channel>
</rss>
