Created
August 29, 2012 18:05
-
-
Save codeimpossible/3516357 to your computer and use it in GitHub Desktop.
<< evaluation in Ruby
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 find(since=nil, til=nil) | |
@where << since ? " AND C.time >= #{since}" : "" | |
@where << til ? " AND C.time <= #{til}" : "" | |
find_by_sql make_sql #assume this generates SQL statement using @where and some other stuff... | |
end | |
# Question 1: Why does the above fail with this error: | |
# TypeError: can't convert nil into String | |
# from (irb):3:in `<<' | |
# from (irb):3 | |
# | |
# Question 2: How can we make this pass with the fewest code changes? | |
# Question 3: Is there another syntax we could use that would do the same thing? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The comments are bit light to read on a white background. Here they are:
Question 1: Why does the above fail with this error:
Question 2: How can we make this pass with the fewest code changes?
Question 3: Is there another syntax we could use that would do the same thing?