Dev box
I'm a 32-year-old Ruby on Rails web developer. With the help of friends and co-workers, I've been teaching myself Rails. I worked as a Rails developer for Crowd911 in Colorado. I live in Berlin.
In my developer blog I publish a stochastic array of thoughts and ideas, lessons, mistakes, questions and attempts as answers about Rails and Ruby. I am also posting Anki cards that I used to help myself study. In my view most knowledge is about practice. If you have thoughts, questions, ideas, corrections, arguments, feel free to email me at henryvw@gmail.com.

What is the Ruby & (ampersand) Thing?

The Ruby & ampersand is a shortcut, a "piece of syntactic sugar", to use for writing "loop through and do this".

So:

[paul, ringo, starr].map( &:capitalize )

replaces

[paul, ringo, starr].map( |beatle| beatle.capitalize )

 

Read More

What's the Basic Difference in Ruby Between .each and .map?

The answer is simple.

.each iterates through an array and outputs stuff WITH it

.map iterates through an array and outputs stuff TO it

.map! iterates through an array and outputs stuff TO it - permanently changing the original array

 

 

yammie = [1,2,3]

 

yammie.each do |y|

  puts y + 1

end

OUTPUTS:

=> [1, 2, 3]  (The original array. No changes.]

 

yammie = [1,2,3]

yammie.each do |y|

  puts y + 1

end

OUTPUTS:

=> 2, 3, 4  (From the 'puts'. Notice - it's NOT an array. Just an output.)

[1, 2, 3]  (the original array)

 

yammie = [1,2,3]

yammie.map do |y|

  y + 1

end

OUTPUTS:

=> [2,3,4]  (a new array that's been ALTERED)

yammie

=> [1,2,3]

yammie itself is still its own array. To PERMANENTLY alter the yammie array ITSELF, and not just output a new altered array, you would use .map! (exclamation point).  

Read More

What is an Exception?

An "exception" is an anomolous condition that causes the normal flow of the execution of a program to break, or to require special handling.

 

Read More
Errors

Writing or Debugging Failing RSpec Tests

Binding.pry

- "next" (means you "step over" - you will go to the next "line" of code, "ignoring" the inner guts of methods that you're calling.

- "step" (means you "step into" the stack trace - so for example, on the next line is a method from a gem, "step" will go into that method. ) 

- "continue"

- "save and open page" - when you're doing view related tests, it takes the current state of the test and opens it in a browser for you.

- "exit!" - say you're stuck in a loop, it's a way to get out of even queud breakpoints

- "ls" show all methods that are available 

- "pry-backtrace" - for showing and listing the current stack

Read More
RSpec

A Manifesto of Learning at Work

What if I wrote a kind of manifesto of learning?

I will be honest with my questions.

I will be honest about my time.

I will take the time to learn when I need to learn, rather than pretending that I am doing work.

I will ask for help honestly when I need it, even if it makes me look under-qualified for my job.

I will view programming problems as opportunities to learn. What is the opportunity here for me to learn?

Read More
Learning, Work, Manifestoes






Footerfull