Since a symbol is just an interned string you can use "key#{i}".intern
(or .to_sym) to cast it to a symbol.

On 29 May 2012 21:28, rooby shoez <lists / ruby-forum.com> wrote:
> I had this
>
> =A0 =A0 =A0 =A0{
> =A0 =A0 =A0 =A0key0: OpenSSL::Digest::SHA256.new.digest("1 #{key}"),
> =A0 =A0 =A0key1: OpenSSL::Digest::SHA256.new.digest("2 #{key}"),
> =A0 =A0 =A0key2: OpenSSL::Digest::SHA256.new.digest("3 #{key}"),
> =A0 =A0 =A0key3: OpenSSL::Digest::SHA256.new.digest("4 #{key}")
> =A0 =A0 =A0}
>
> I want this
>
> subkeys =3D {}
> 4.times do |i|
> subkeys[:key"#{i}"] =3D OpenSSL::Digest::SHA256.new.digest("#{i} #{key}")
> end
>
> --
> Posted via http://www.ruby-forum.com/.
>



--=20
=A0 Matthew Kerwin, B.Sc (CompSci) (Hons)
=A0 http://matthew.kerwin.net.au/
=A0 ABN: 59-013-727-651

=A0 "You'll never find a programming language that frees
=A0 you from the burden of clarifying your ideas." - xkcd