[swift-evolution] [Idea]Why not get dynamically named variables?

Saagar Jha saagar at saagarjha.com
Sun Sep 4 12:32:48 CDT 2016


Have you thought about using a dictionary? You can fetch a recipe by looking up a key:

let foods: [String: Foods] = [:] // fill it up appropriately with your own data
let recipe = foods[TitleTextField.text].recipe

Saagar Jha



> On Sep 4, 2016, at 10:28, Fayez Hellani via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Hey! There should be an option to name variables AND constants dynamically. For e.g. in an app from storing recipes, where the user creates a recipe,the recipe should be stored in a constant (as a structure) with a name “\(TitleTextField.text)_Recipe” (e.g. “Lasagna_Recipe”), so that it gets stored easily and therefore fetched even easier.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160904/278a2fbf/attachment.html>


More information about the swift-evolution mailing list