From: Bertram Scharpf Date: 2009-12-22T20:02:31+09:00 Subject: Re: Symbols vs. constants? Hi, Am Dienstag, 22. Dez 2009, 09:57:28 +0900 schrieb Sonja Elen Kisa: > How are symbols and constant (capitalized) strings similar or > dissimilar? They both seem to be used to store text that is not intended > to change. In what situations should I use one or the other? How should > I separate them in my brain? Constants are variables: X = "hello" X = "bye" # not allowed (just a warning) X.replace "bye" # this is allowed! X.freeze X.replace "hi again" # forbidden (TypeError) But you can also freeze other variables: x = "foo" x.freeze x.replace "bar" # forbidden (TypeError) Symbols are objects but do not have no `replace' method neither `sub', `gsub', `tr', `succ!', and what else could change its contents. x = :foo X = :bar x.replace sth # forbidden (NoMethodError) Could it be that I didn't use `freeze' for years? Did I miss something? Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany * Discover String#notempty? at .