This file contains 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, b, c = 50, 'cent', :test | |
# a => 50 | |
# b => 'cent' | |
# c => :test |
This file contains 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
name = 'John' | |
# default acts as double-quoted string | |
puts <<heredoc | |
Hello #{name} | |
other line 1, | |
other line 2. | |
heredoc | |
# double-quoted string |
This file contains 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..10) === 4 # => true | |
(1...10) === 10 # => false |
This file contains 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 = "world") | |
puts "hello #{name}!" | |
end | |
hello # => hello world! | |
hello('John') # => hello John! |
This file contains 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 yo | |
if block_given? | |
yield | |
else | |
puts "No block :-(" | |
end | |
end | |
yo # => No block :-( | |
yo { puts "Yo man" } # => Yo man |
This file contains 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
lang = 'en' | |
welcome_msg = case lang | |
when 'en' then 'welcome' | |
when 'de' then 'willkommen' | |
when 'fr' then 'bienvenue' | |
when 'de' then 'bienvenida' | |
else 'yo' | |
end |
This file contains 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
$('<div id="test"><p><a>John</a></p></div>').find('a').attr('href' , 'http://phrappe.com/').end().appendTo('body'); |
This file contains 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
<p>Hello World!</p> // Markup $('p:contains("Hello")'); |
This file contains 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
$('li.old').replaceWith('<li>new li</li>'); |
This file contains 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
$('h1', 'div#posts'); //using jQuery wrapper as context |
OlderNewer