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
use std::io; | |
use std::io::Write; | |
fn main() { | |
//println! is a macro that writes a line to stdout and then flushes the | |
//stdout buffer | |
println!("The inredibly annoying Rust echo strikes again!"); | |
//get a reference to stdin | |
let stdin = io::stdin(); |
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
extern crate regex; | |
use regex::Regex; | |
/* | |
1. At least 1 "cool" adjective ("horrendous", "incredible", "monstrous", "ultimate") | |
2. A science-sounding intermediate noun ("space", "time", "matter", "energy") | |
3. An onomatopoeia that makes a cool sound ("boom", "kablooie", "swoosh") | |
*/ | |
pub fn is_scientific_name(input: &str) -> bool { |
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
//from scientific_names.lalrpop | |
// parse the final noun of a scientific name. | |
// match it to one of the legal final nouns. | |
pub FinalNoun : FinalNoun = { | |
"kablooie" => FinalNoun::Kablooie, | |
"swoosh" => FinalNoun::Swoosh, | |
"frobber" => FinalNoun::Frobber, | |
"atomizer" => FinalNoun::Atomizer, | |
"event" => FinalNoun::Event, | |
"device" => FinalNoun::Device, |
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
//src/main.rs | |
mod rectangle; | |
fn main() { | |
println!("Hello, world!"); | |
} | |
//src/point.rs | |
#[derive(Debug)] | |
pub struct Point { |
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
//src/main.rs | |
mod rectangle; | |
mod point; | |
fn main() { | |
println!("Hello, world!"); | |
} | |
//src/point.rs | |
#[derive(Debug)] |
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# All Vagrant configuration is done below. The "2" in Vagrant.configure | |
# configures the configuration version (we support older styles for | |
# backwards compatibility). Please don't change it unless you know what | |
# you're doing. | |
Vagrant.configure("2") do |config| | |
config.vm.box = "ubuntu/trusty64" |
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 HasInstanceMethods | |
def instance_method | |
puts "In instance method, the type of `self` is #{self.class}" | |
end | |
def self.class_method | |
puts "In class method, the type of `self` is #{self.class}" | |
end | |
def call_class_from_instance |
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
using System; | |
namespace ConsoleApplication | |
{ | |
public class HasInstanceAndStaticMethods | |
{ | |
public static void StaticMethod() | |
{ | |
Console.WriteLine("Hello from static method"); | |
} |
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 CSharpStyle | |
def method_missing method_name, *args | |
self.class.send(method_name, *args) | |
end | |
def self.static_method | |
puts "hurray for Ruby" | |
end | |
def instance_method |
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 Stubbable | |
def stub(name, block) | |
send(:define_singleton_method, name, block) | |
end | |
end | |
class Class | |
def stub(name, block) | |
send(:define_singleton_method, name, block) | |
end |
OlderNewer