Question: I have this question in a homework assignment for my Computer Languages class. I'm trying to figure out what each one means, but I'm getting stuck.

> 
> Errors in a computer program can be
>  classified according to when they are
>  detected and, if they are detected at
>  compile time, what part of the
>  compiler detects them. Using your
>  favorite programming language, give an
>  example of:
> 
> 
> (a) A lexical error, detected by the
>  scanner.
> 
> 
> (b) A syntax error, detected by the
>  parser.
> 
> 
> (c) A static semantic error, detected
>  (at compile-time) by semantic
>  analysis.
> 
> 
> (d) A dynamic semantic error, detected
>  (at run-time) by code generated by the
>  compiler.
> 
> 
> 

For (a), I think this is would be correct: `int char foo;`

For (b), `int foo` (no semicolon)

For (c) and (d), I'm not sure what is being asked.

Thanks for the help.

Answer: 
UPDATE: Rails 5:

```
ActiveRecord::Type::Boolean.new.deserialize('0')

```

UPDATE: Rails 4.2 has public API for this:

```
ActiveRecord::Type::Boolean.new.type_cast_from_user("0") # false

```

PREVIOUS ANSWER:

ActiveRecord maintains a list of representations for true/false in <https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/column.rb>

```
2.0.0-p247 :005 > ActiveRecord::ConnectionAdapters::Column.value_to_boolean("ON")
2.0.0-p247 :006 > ActiveRecord::ConnectionAdapters::Column.value_to_boolean("F")

```

This is not part of Rails' public API, so I wrapped it into a helper method:

```
class ApplicationController < ActionController::Base
  private

  def parse_boolean(value)
    ActiveRecord::ConnectionAdapters::Column.value_to_boolean(value)
  end
end

```

and added a basic test: 

```
class ApplicationControllerTest < ActionController::TestCase
  test "parses boolean params" do
    refute ApplicationController.new.send(:parse_boolean, "OFF")
    assert ApplicationController.new.send(:parse_boolean, "T")
  end
end

```
You could convert all your boolean params to real booleans like this:

```
%w(show_all, show_featured).each do |bool_param|
  params[bool_param.to_sym] = params[bool_param.to_sym] == "true"
end

```

In this solution, nil parameters would become false.