This file contains hidden or 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
| import android.content.Context; | |
| import android.graphics.Canvas; | |
| import android.graphics.LinearGradient; | |
| import android.graphics.Paint; | |
| import android.graphics.Path; | |
| import android.graphics.Shader; | |
| import android.util.AttributeSet; | |
| import android.widget.LinearLayout; | |
| import com.movl.swipeit.R; |
This file contains hidden or 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
| def some_method | |
| @some_method ||= some_expensive_op | |
| end |
This file contains hidden or 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
| @list.map(&:to_i) | |
| # vs | |
| @list.map { |x| x.to_i } |
This file contains hidden or 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
| def sometimes_block | |
| if block_given? | |
| Proc.new.call | |
| end | |
| end | |
| sometimes_block { puts "hi" } | |
| sometimes_block |
This file contains hidden or 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 Foo | |
| def explicit & block | |
| yield | |
| end | |
| def implicit | |
| yield | |
| end | |
| end |
This file contains hidden or 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 Foo | |
| def foo; end | |
| define_method :bar do; end | |
| class_eval %{ def baz; end } | |
| end |
This file contains hidden or 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
| lambda {...} # vs | |
| class Callable | |
| def call; .. end | |
| end |
This file contains hidden or 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
| %w{ | |
| Foo | |
| Bar | |
| Baz | |
| }.inject(Object) { |klass, string| | |
| klass.const_get(string.to_sym) | |
| } |
This file contains hidden or 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
| values = some_list.map { |val| | |
| [val, some_transform(val)] | |
| } | |
| Hash[values] |
This file contains hidden or 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
| some_list.inject({}) do |hash, val| | |
| hash[val] = some_transform(val) | |
| hash | |
| end |