使用Swift 3向数组添加值

时间:2017-08-14 06:40:03

标签: swift

我正在努力解决如何在下面的数组中添加值:

   struct Location {
        let title: String
        let latitude: Double
        let longitude: Double
        let phone: Double
    }

    var locations = [
        Location(title: "New York, NY",    latitude: 40.713054, longitude: -74.007228, phone: <#Double#>),
        Location(title: "Los Angeles, CA", latitude: 34.052238, longitude: -118.243344, phone: <#Double#>),
        Location(title: "Chicago, IL",     latitude: 41.883229, longitude: -87.632398, phone: <#Double#>)
    ]

1 个答案:

答案 0 :(得分:1)

你可以append这样的新位置:

@Controller
public class LoginController {

    @RequestMapping(value="/login", method=GET)
    public String login(Principal principal) {
        return principal == null ?  "login" : "redirect:/"; 
    }
}