From: Fily Salas Date: 2011-11-25T00:55:06+09:00 Subject: Understanding Ruby blocks Hi, I have been practicing Ruby and believe it or not the hardest part for me to understand (so far) is the concept of using blocks, why used them and how to use them. For instance, I know I don't fully understand blocks but why would you use a block in the following situation. text = "Some Text" File.open('test_file.txt', 'a+') do |file| file.write(text) end Why not just ...? text = "Some Text" file = File.open('test_file1.txt', 'a+') file.write(text) ..why use a block instead? 1-What would be a good rule of thumb to know when to use blocks? 2-What would be the easiest way to understand block? 3-Can someone be so kind and explain block a little bit? Thanks a lot for all of your help! Learning a lot in this forum. Awesome people! -- Posted via http://www.ruby-forum.com/.