Finally [v1.1.14+]

try ¼­¼ú¹®ÀÇ ½ÇÇà ÈÄ¿¡ Çϳª ÀÌ»óÀÇ ¼­¼ú¹® (¸í·É¾î ¶Ç´Â Ç¥Çö½Ä)À» Ç×»ó ½ÇÇàÇÕ´Ï´Ù.

Finally Statement
Finally
{
    Statements
}

³íÆò

finally¸¦ »ç¿ëÇÒ ¶§¸¶´Ù À§¿¡ ÀÖ´Â try (¶Ç´Â catch) ¼­¼ú¹®¿¡ (¿¬°üµÇ¾î ÀÖ¾î¾ß) ¼ÓÇØ¾ß ÇÕ´Ï´Ù. finally´Â ¾ðÁ¦³ª °¡Àå °¡±î¿î À§ÀÇ try ¼­¼ú¹®¿¡ ¼ÓÇÕ´Ï´Ù. blockÀÌ »ç¿ëµÇ¾î ±× ÇàÀ§°¡ º¯°æµÈ °æ¿ì´Â Á¦¿ÜÇÕ´Ï´Ù.

Try ¼­¼ú¹®Àº catch ¶Ç´Â finally°¡ Á¸ÀçÇϴ°¡¿¡ µû¶ó ´Ù¸£°Ô ÇൿÇÕ´Ï´Ù. ´õ ÀÚ¼¼ÇÑ Á¤º¸´Â Try¸¦ ÂüÁ¶ÇϽʽÿÀ.

Goto, break, continue ±×¸®°í returnÀº try ºí·Ï ¾ÈÀÇ Á¦¾î È帧 Áö½Ã¾î¸¦ ¾ïÁ¦ÇÏ·Á¸é ²À ÇÊ¿äÇÏÁö¸¸ finally ºí·ÏÀ» Á¾·áÇÏ´Â µ¥´Â »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù. ¿¹¸¦ µé¾î, try°¡ return 42¸¦ »ç¿ëÇÑ´Ù¸é, finally ºí·ÏÀÌ ½ÇÇàµÈ ÈÄ °ª 42°¡ ¹ÝȯµË´Ï´Ù. ´ÙÀ½ ¸í·É¾î Áß Çϳª¸¦ »ç¿ëÇÏ¿© finally ºí·ÏÀ» ºüÁ® ³ª¿À·Á´Â ½Ãµµ´Â ÀûÀç ½Ã°£¿¡ ±×·¸Áö ¾ÊÀ¸¸é ½ÇÇà ½Ã°£¿¡ °¡´ÉÇÏ¸é ¿¡·¯·Î ŽÁöµË´Ï´Ù.

v1.1.19.02 ÀÌÀü¿¡¼­, finally ¼­¼ú¹®ÀÌ Á¸ÀçÇϸé try ¾ÈÀÇ Á¦¾î È帧 ¼­¼ú¹®ÀÌ ÀÛµ¿ÇÏÁö ¸øÇÏ´Â ¹ö±×°¡ ÀÖ¾ú½À´Ï´Ù. ReturnÀÌ finally ¾È¿¡¼­ Çã¿ëµÇ´Â ¹ö±×°¡ ÀÖ¾úÁö¸¸, ¿¹¿Ü¸¦ ´øÁ®µµ ¹«½ÃµÇ¾ú½À´Ï´Ù.

One True Brace (OTB) ½ºÅ¸ÀÏÀº ¼±ÅÃÀûÀ¸·Î finally ¸í·É¾î¿Í ÇÔ²² »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù:

try {
    ...
} finally {
    ...
}

try {
    ...
} catch e {
    ...
} finally {
    ...
}

°ü·Ã Ç׸ñ

Try, Catch, Throw, ºí·Ï

¿¹Á¦

try
{
    ToolTip, Working...
    Example1()
}
catch e
{
    ; e°¡ ´ã°í ÀÖ´Â °´Ã¼¿¡ °üÇÑ ´õ ÀÚ¼¼ÇÑ Á¤º¸´Â, Catch¸¦ ÂüÁ¶ÇϽʽÿÀ.
    MsgBox, 16,, % "Exception thrown!`n`nwhat: " e.what "`nfile: " e.file
        . "`nline: " e.line "`nmessage: " e.message "`nextra: " e.extra
}
finally
{
    ToolTip ; ÅøÆÁÀ» °¨Ãä´Ï´Ù
}

MsgBox, Done!

; ÀÌ ÇÔ¼ö¿¡ ÀÖ´Â Finally ºí·ÏÀº  û¼Ò ÄÚµå·Î ÇàÀ§ÇÕ´Ï´Ù.
Example1()
{
    try
        Example2()
    finally
        MsgBox, ¿©±â´Â ¿¹¿Ü¿¡ »ó°ü¾øÀÌ ¾ðÁ¦³ª ½ÇÇàµË´Ï´Ù.
}

; ÀÌ ÇÔ¼ö´Â ºÐÀÌ È¦¼öÀÌ¸é ½ÇÆÐÇÕ´Ï´Ù.
Example2()
{
    if Mod(A_Min, 2)
        throw Exception("Test exception")
    MsgBox, Example2 did not fail
}