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
<script> | |
$(document).ready(function(){ $('a').click(function(){ goToByScroll($(this).attr('href')); return false; }); }); | |
function goToByScroll(id){ $('html,body').animate({scrollTop: $(id).offset().top},'slow'); } | |
</script> |
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
class Party | |
{ | |
var time: NSDate | |
var location: CGPoint | |
var guests: Array | |
// ... | |
} | |
class Guest |
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
// Here we explicitly specify the type | |
var beverage: String = "Leffe" | |
// But the type can also be inferred from the fact that we're assigning it a String value | |
var name = "Leffe" |
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
// vars | |
var mutableBeverage = "Leffe" | |
println(mutableBeverage) // "Leffe" | |
mutableBeverage = "Bud" | |
println(mutableBeverage) // "Bud" | |
mutableBeverage = mutableBeverage + "weiser" | |
println(mutableBeverage) // "Budweiser" |
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
// Non-optional vars | |
var mutableBeverage = "Leffe" | |
println(mutableBeverage) // "Leffe" | |
mutableBeverage = "Bud" | |
println(mutableBeverage) // "Bud" | |
mutableBeverage = mutableBeverage + "weiser" | |
println(mutableBeverage) // "Budweiser" |
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
NSString *costume = @"Dracula"; | |
// ... | |
if (costume == nil) { | |
// Do something for this plain clothes guest | |
} else { | |
// Do something else for this costumed guest | |
} |
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
var costume: String? = "Werewolf" | |
println(costume) // Optional("Werewolf") | |
costume = costume + " dressed as Michael J Fox" // Compiler Error | |
if let something = costume { | |
// The value is not nil, use it with confidence | |
something = something + " dressed as Michael J Fox" | |
println(something) // "Werewolf dressed as Michael J Fox" | |
} else { |
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
var costume: String? = "Werewolf" | |
println(costume) // Optional("Werewolf") | |
costume = costume! + " dressed as Michael J Fox" | |
println(costume) // Optional("Werewolf dressed as Michael J Fox") |
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
toppings = %w(pepperoni mushroom bacon pineapple) | |
def pizza(toppings) | |
toppings.each do |topping| | |
puts "I love #{topping} pizza!" | |
end | |
end |
OlderNewer