Created
October 13, 2012 10:36
-
-
Save kenmazaika/3884111 to your computer and use it in GitHub Desktop.
oh_my_goodness.java
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
| 1.9.2p290 :002 > class String | |
| 1.9.2p290 :003?> def quote | |
| 1.9.2p290 :004?> "'#{self}'" | |
| 1.9.2p290 :005?> end | |
| 1.9.2p290 :006?> end | |
| => nil | |
| 1.9.2p290 :007 > def omgLifeIsWonderful(language) | |
| 1.9.2p290 :008?> unless language.blank? | |
| 1.9.2p290 :009?> "I program in the language #{language.quote} and life is wonderful" | |
| 1.9.2p290 :010?> else | |
| 1.9.2p290 :011 > "I could program because it's easy" | |
| 1.9.2p290 :012?> end | |
| 1.9.2p290 :013?> end | |
| => nil | |
| 1.9.2p290 :014 > omgLifeIsWonderful('ruby') | |
| => "I program in the language 'ruby' and life is wonderful" | |
| 1.9.2p290 :015 > |
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
| package com.lifeIsTerrible.andIHateIt; | |
| import java.lang.StringBuilder; | |
| class OhMyGoodness extends ReasonsIBingeDrinkEveryDay { | |
| string omgIWantToDie(String language) { | |
| if( ! org.apache.commons.lang.StringUtils.isBlank(language) { | |
| StringBuilder strBuilder = new StringBuilder(); | |
| strBuilder.append("I programming in the language "); | |
| String quotedLanguage = org.springframework.util.StringUtils.quote(language); | |
| strBuilder.append(quotedLanguage); | |
| strBuilder.append(" and I want to die."); | |
| return strBuilder.toString(); | |
| } | |
| else { | |
| return "I don't code, because it's too hard."; | |
| } | |
| } | |
| } | |
| # omgIWantToDie("java"); | |
| # => "I program 'java' and I want to die." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment