Scala中的多变量赋值

时间:2017-08-21 20:22:40

标签: scala

我正在读斯卡拉的书,其中一个练习如下:

提出一种情况,即作业x = y = 1在Scala中有效。 (提示:为x选择合适的类型。)

我能提出的两个解决方案是:

val x, y : Int = 1
val x, y = (1, 2)

我是否错过了练习所需的其他方式?

1 个答案:

答案 0 :(得分:1)

“有效”和“有用”并不一定意味着相同的事情:)

 <tbody>
    @foreach (Reservation r in Model)
    {
        string alertClass = "";
        if (ViewBag.Varovani == true)
        {
            alertClass = "danger";
        }
        else
        {
            alertClass = "";
        }
        <tr class="@alertClass">

            <td>@r.Reserved.Id</td>
            <td>@r.Name</td>
            <td>@r.DateFrom</td>
            <td>@r.DateTo</td>
            <td>

                   @Ajax.ActionLink("Detail", "Detail", "Skies", new { id = r.Reserved.Id }, new AjaxOptions() { InsertionMode = InsertionMode.Replace, UpdateTargetId = "modalContent", OnBegin = "openModalWindow" })

            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", "Reservation", new { id = r.Id }, null)
                @Html.ActionLink("Delete", "Delete", "Reservation", new { id = r.Id }, new { onclick = "return confirm('Přejete si opravdu smazat tuto výpujčku? " + r.Name + "');" })
            </td>
        </tr>
        }
</tbody>