Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Angelo Pozzato
6,555 PointsSwift: Statement are not allowed at the top level
Hi
im having an issue.. i making and app and wanted to make a new .swift file with some arrays and functions in it.. and now i want to make a for-in loop, but i get the error "Statement are not allowed at the top level".. I really have no idea what this means, any help? :)
//Regards Rasmus
1 Answer
agreatdaytocode
24,757 PointsHello Rasmus,
The top-level code in a Swift source file consists of zero or more statements, declarations, and expressions. By default, variables, constants, and other named declarations that are declared at the top-level of a source file are accessible to code in every source file that is part of the same module. You can override this default behavior by marking the declaration with an access level modifier, as described in Access Control Levels.
Check out this link
I'll search around for a better answer but this should get you started.
agreatdaytocode
24,757 Pointsagreatdaytocode
24,757 PointsCan you share the code?