Comments (1)
- Credit : @kaochenlong
🎉 - 消息來源 : FB 龍哥臉書
- 題目出處 : Gist 某校期中考題目
- 有幾題是5xruby的面試題
- 已取得 @kaochenlong 授權張貼
Ruby 題目
- 請完成本題實作內容
class Cat
# 請完成實作
end
kitty = Cat.new("kitty")
puts kitty.name # 在畫面上印出 kitty 字樣
- 假設有個 Hash:
profile = {name: "kk", age: 18}
當執行這行程式:
p profile["name"]
會得到什麼結果? 為什麼?
-
如果要在 1 到 100 的數字當中,任意取出 5 個不重複的亂數,你會怎麼做?
class Bank
def transfer(amount)
# ...
end
end
Bank.transfer(10)
上面這段程式碼執行後會發生什麼事?為什麼?如果有錯誤又該如何修正?
- 請問以下方法:
link_to "刪除", products_path(product), method: :delete, class: "btn btn-default"
link_to
方法共有幾個參數?為什麼?
- 在 Ruby 裡面常會看到冒號的寫法,例如:
有的冒號靠右邊:
class Store
has_many :products
end
有的冒號靠左邊:
link_to "檢視", books_path(book), class: "btn btn-default"
或是兩邊都有:
user_profile = {name: "kk", age: 18, blood_type: :b_negative}
請問,這三種寫法分別代表什麼意思呢?
Rails 題目
-
請簡述
bundle install
指令的用途。 -
請說明
rails db:migrate
這個指令的用途是什麼? -
假設某個 Controller 的程式碼如下:
class BooksController < ApplicationController
def index
@books = Book.all
end
def update
@book = Book.find_by(id: params[:id])
@book.update(price: 100)
redirect_to books_path, notice: "資料更新成功"
end
end
請問:
- 第 3 行的
@books
前面的那個@
是什麼意思?如果把@
拿掉會發生什麼事? - 第 7 行以及第 8 行的
@book
,如果把@
拿掉會發生什麼事?為什麼?
Git 題目
-
在你想像中的分支(branch),是個什麼樣子的東西?
-
空的資料夾無法被加入 Git 版控,但如果就是想讓這個資料夾留下來,你會怎麼處理?
-
如果有些檔案,像是
/config/database.yml
之類比較機密的檔案,不想放在 Git 裡面,你會怎麼做?
額外加分題
在之前的作業中曾寫到:
def odd_number_calculator(n)
# 實作內容
[*1..n].select(&:odd?).reduce(:+)
end
puts odd_number_calculator(100) # 得到 2500
上述程式中,第 3 行的select
方法使用 (&:odd?)
以及 reduce
方法後面接了 :+
的意思是什麼呢?
from ama.
Related Issues (20)
- 想請問一下 遠端機器環境建置問題 HOT 5
- fork gem 後指定 gem source 為自己的 github,capistrano deploy bundle 錯誤 HOT 10
- 請教Devise的問題 HOT 1
- 實作 Agile Web Development With Rails 4 HOT 5
- Agile Web Development With Rails 4 Chapter 11.5
- Agile Web Development With Rails 4 Chapter 11.5
- ActionCable 佈署到 production 後 WebSocket connection failed HOT 4
- 如何直接取得hash的size並作運算 HOT 2
- About rails breadcrumbs gem
- Rails5 WebSocket 偶爾 handshake 404 HOT 2
- 請問關於加密的問題 HOT 2
- 請問為何 better_errors 無法在 Rails 4.2.0 + Ruby 2.2.0 上使用? HOT 2
- 詢問 space 和 tab 轉換工具 HOT 6
- 請問要如何實做複選框+背景新增值的功能,或是有那種複選tagging的功能? HOT 11
- 為什麼 deep_dup 實作卻只是呼叫 dup HOT 1
- 請教一下,我把專案從Rails 4.2升級到 5.2,忽然Devise就無法登出了!!! HOT 5
- 請教一下,如何讓一個驗證失敗後就停住? HOT 2
- 想請教一下,如何讓事件點進去能在 Daterangepicker 顯示正確日期? HOT 3
- 商务
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ama.