Would it be cowardly for me to go ahead and say agencies are an exception?
I worked at an agency (HUGE in Brooklyn), and was very close to what freelancing is in regard to learning.
It's a steady paycheck, but you're always working on different project, and they're usually fairly cutting edge.
Being surrounded by awesome developers is important too, but you can get that in a co-working space, attending meetups, being part of and contributing to some open-source community, or just hanging out with your developer friends.