Skip to content

Instantly share code, notes, and snippets.

@bazz1tv
bazz1tv / scope.rb
Created May 1, 2016 06:42
Ruby class definition scoping
class A
a = "DERP"
@a = "BARF"
@@a = "FETUS"
puts a
puts @a
end
class A
@bazz1tv
bazz1tv / file.rb
Last active May 1, 2016 05:18
ruby file append | add trailing newline if necessary
# it's a little out of context, but you get the idea
File.open(@dict.filename, 'a+') do |f|
f.seek(-1, IO::SEEK_END)
f << "\n" if f.getc != "\n"
f << word << "\n"
end