statements change the environment, expressions do not
do-nothing statement を定義
- 簡約した結果を再び代入
- Environmentは変化しない
# file spec/libs/lottery_spec.rb | |
require 'spec_helper' | |
RSpec.describe 'lib/lottery' do | |
describe 'Lottery.pick' do | |
let(:characters) { create_list(:character, 2) } | |
let(:num_samples) { 10000 } | |
subject do | |
num_chosen = 0 | |
num_samples.times do |
#include <iostream> | |
#include <unistd.h> | |
class bar{ | |
public: | |
bar(){} | |
~bar(){} | |
void setLambda(std::function<void()> func){ | |
_func = func; | |
} |
#include <iostream> | |
#include <unistd.h> | |
class myClass{ | |
public: | |
myClass(){ | |
std::cout << "constructor called" << std::endl; | |
} | |
~myClass(){ | |
std::cout << "destructor called" << std::endl; |
#include "dist/json/json.h" | |
int main(void){ | |
Json::Reader reader; | |
Json::Value rootJson; | |
bool parseResult = reader.parse(" \ | |
\"areas\" : [ \ | |
{\ | |
\"background_image\" : \"background_cave\",\ | |
\"description\" : \"desc\",\ |
#include <iostream> | |
class Super{ | |
public: | |
virtual void func(){ | |
std::cout << "super" << std::endl; | |
} | |
virtual Super* someFunc(){ | |
std::cout << "Super::someFunc()" << std::endl; |
#include <iostream> | |
#include <unistd.h> | |
class bar{ | |
public: | |
bar(){} | |
~bar(){} | |
void setPointer(void* pointer){ | |
std::cout << "setPointer called" << std::endl; | |
_pointer = pointer; |
class SomeClass{ | |
public: | |
virtual void func() { | |
std::cout << "SomeClass::func called" << std::endl; | |
} | |
}; | |
class SubOfSomeClass : public SomeClass { | |
public: | |
virtual void func() override { |
*.cpp filter=cpplint_cleaner | |
*.h filter=cpplint_cleaner |
double throwDice() { | |
std::random_device rd; | |
std::mt19937 gen(rd()); | |
std::uniform_real_distribution<> dis(0, 1); | |
return dis(gen); | |
} | |
template<class T> | |
typename std::vector<T>::const_iterator lottery( | |
const std::vector<T>& list, |