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: 
I wanted to comment on zetetic answer but as I can't do that yet I'll post this as an answer. 

If you use 

`@show_all = params[:show_all] == "1"` 

then you can drop `? true : false` because `params[:show_all] == "1"` statement itself will evaluate to true or false and thus ternary operator is not needed.
It's worth noting that if you're passing down a value to an **ActiveModel** in Rails > 5.2, the simpler solution is to use `attribute`,

```
class Model
  include ActiveModel::Attributes

  attribute :show_all, :boolean
end

Model.new(show_all: '0').show_all # => false

```

As can be seen [here](https://api.rubyonrails.org/classes/ActiveModel/Attributes/ClassMethods.html#method-i-attribute_names).

---

Before 5.2 I use:

```
class Model
  include ActiveModel::Attributes

  attribute_reader :show_all

  def show_all=(value)
    @show_all = ActiveModel::Type::Boolean.new.cast(value)
  end
end

Model.new(show_all: '0').show_all # => false

```